Payload

Cloud code is a single function that is called with a payload. The payload contains data and information regarding the message that triggered the action and user.

/**
@param {object} payload - data and info
@param {string} payload.channelName - type of channel
@param {string} payload.query - what the user sends
@param {object} payload.params - data detected by AI
@param {object} payload.user - user that triggered the action
@param {string} payload.user.name - name of the user
@param {string} [payload.user.profile.firstName] - first name of the user
@param {string} [payload.user.profile.lastName] - Last name of the user
@param {string} [payload.user.profile.fullName] - first and last name combined
@param {string} [payload.user.profile.picture] - profile picture
@param {string} [payload.user.profile.locale] - user language
*/
(function(payload) {
    // Your custom logic
})

channelName

With each call we send the type of channel. This is a simple string like socket or alexa.

API and webwidget

Both using our Socket API or Web widget are the socket channel

query

Usually a piece of Code is triggered by a user saying something or sending a text message. If so, this property will contain the query.

params

Params contain any data extracted by the AI engine, or that is send by other integrations or channels

user

This object contains profile information regarding the user triggering the Code action. Except name, most profile information is optional.

Property Description
name
profile.firstName Optional first name of the user
profile.lastName Optional last name of the user
profile.fullName Optional first and last name combined
profile.picture Optional profile picture
profile.locale Optional user language