Payload
A code action is a single function that is called along with a payload. The payload contains metadata regarding the message and user that triggered the action.
/**
@param {object} payload - data and info
@param {string} payload.threadId - Identifier for the conversation
@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
@param {string} [payload.user.profile.gender] - user gender
@param {object} payload.match - matching flow and step
@param {object} payload.match.flow - contains name and flowId of matching flow
@param {object} payload.match.step - contains name and stepId of matching step
*/
async payload => {
// Your custom logic
}
threadId
The threadId is a unique identifier that represents the conversation. For some channels, this identifier represents the user. For example, with Messenger, this is the page specific ID (PSID).
channelName
With each call you als receive the type of channel. This is a simple string like socket
, whatsapp
or rcs
.
API and webwidget
Both the Socket API and Web widget are the socket channel.
query
Usually, an action 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 sent by other integrations or channels
user
This object contains profile information regarding the user triggering the Code action. Except for the 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 |
tags | A list of (optional) tags applied |
match
The match object will contain the matched step
and flow
.
Updated 11 months ago