Skip to content

Working with Cloud Functions


When a bot requests the execution of a cloud function, it sends clearly structured data to support the execution of the function. Each function will get up to two arguments i.e.

function exampleCloudFunction(userData, postbackPayload?) {
  • userData

    This object is provided every time a cloud function is invoked. It contains values of all Meta and Custom Slots as shown below:

userData = {
  metaData: {
  slotData: {
     * The slot data is in the format of
     * <Slot Name>: <Slot Value>. For e.g.
     * {
     *    middleName: "McGregor"
     * }
     * All the slots will be listed. Even
     * if they do not have value.
  • postbackPayload

    This parameter is an optional parameter which is defined only when the trigger source for the cloud function is a Postback Button.

    In case the trigger source is a postback button, this parameter contains the value of the payload defined on the aforesaid postback button. Otherwise, this parameter is not defined.

Meta Slots

The metaData property in the received userData parameter in the function invocation contains quite a few slots. It is not necessarily true that all the slots will have a value. Which Meta slots have value will depend on the Channel(s) in which your bot is present and available.

NLP Response

Special attention should be paid to the rawNlpResponse Meta slot.

If your bot has methods of reaching a Flow via NLP-based navigation or active navigation, the data in this slot may be stale, as it will always contain the most recent response from your NLP service.

The rawNlpResponse has the following structure:

  rawNlpResponse = {

The dateReceived parameter can be used to validate the time and confirm tha tthe NLP response is related to the invoked cloud function while the responseData will vary based on the NLP service used.

Dynamic Content Toolkit

Your cloud functions can perform its programming and return the appropriate result via the Dynamic Content Toolkit. In most cases, this can be done via an async call to your business' API whose response can be transformed and returned via a Promise.