Flow can inject, evaluate or make use of many conversation variables in the canvas nodes. Below are some examples of the variables available to users.
When nodes support variables or context, the txt
fields are a dropdown that can be changed to msg.
When using the intent detection node, the response from the NLP will be set the payload.result
object.
To get just the intent name, use payload.result.intent
. Or to get the action associated with the intent, payload.result.action
msg :{
payload :{
result: {
intent: 'intent_name',
slots: {},
action: {},
fulfilment: 'message from NLP', //for a single response
fulfillmentResponses: ['array', 'of', 'nlp', 'responses'],
intentDetectionConfidence: 1
}
}
}
When a BaaS node responds, data will be stored in a baas.[alias]
object.
Note that baasAlias
will be replaced with whatever aliases you picked.
Example object:
msg :{
baas :{
baasAlias: {
some: 'response',
data: 'here'
}
}
}
ServisBOT messenger sends a conversation start event whenever a conversation starts. The objects in this event are usable for adjusting your flows, especially the context
values.
{
"system": {
"sessionId": "sessionid",
"conversationId": "convoid",
"organization": "organization",
"identity": "identity",
"region": "region",
"bot": "botname"
},
"context": {
"endpointData": {
"Address": "endpointaddress",
"Organization": "organization",
"Useragent": "useragent",
"EngagementType": "EngagementType",
"Updated": 1573140377768,
"TargetBotReference": "botName",
"Status": "online",
"AllowedDomains": "AllowedDomains",
"anotherAllowedDomain",
"Name": "Endpoint Name",
"Created": 1573140377768
},
"correlationId": "correlationId",
"version": "v2",
"organization": "organization",
"endpoint": "endpointaddress",
"sbRegion": "sbRegion",
"conversations": {
"endpointAddress": "conversationid"
}
}
},
"tenant": {},
"user": {},
"correlationId": "correlationId",
"endpoint": "endpointAddress"
}
Every message back from a user will have similar data provided, but also have the user message provided as user.message
Storing additional data in user.message
makes it available as $variables
in flow.
{
"system": {
"sessionId": "sessionid",
"conversationId": "convoid",
"organization": "organization",
"identity": "identity",
"region": "region",
"bot": "botname"
},
"context": {
"endpointData": {
"Address": "endpointaddress",
"Organization": "organization",
"Useragent": "useragent",
"EngagementType": "EngagementType",
"Updated": 1573140377768,
"TargetBotReference": "botName",
"Status": "online",
"AllowedDomains": "AllowedDomains",
"anotherAllowedDomain",
"Name": "Endpoint Name",
"Created": 1573140377768
},
"correlationId": "correlationId",
"version": "v2",
"organization": "organization",
"endpoint": "endpointaddress",
"sbRegion": "sbRegion",
"conversations": {
"endpointAddress": "conversationid"
}
}
},
"tenant": {},
"user": {},
"correlationId": "correlationId",
"endpoint": "endpointAddress",
"user": {
"message": "hello"
}
}
Once a conversation has started meta data is gathered about the device the user is using to communicate with the bot.
The meta data exposes a property called isMobile
which is true
if the user is on a mobile device (including a tablet), or false if the user is not on a mobile device.
You can access this attribute in your flow under the payload.context.meta.isMobile
key.
An example of the payload with the meta data looks like the following:
{
"system": {
"sessionId": "sessionid",
"conversationId": "convoid",
"organization": "organization",
"identity": "identity",
"region": "region",
"bot": "botname"
},
"context": {
"meta": {
"isMobile": true
}
},
"tenant": {},
"user": {},
"correlationId": "correlationId",
"endpoint": "endpointAddress",
"user": {
"message": "hello"
}
}
An example of a dialogue node using this attribute looks like the following:
To test your flow is correctly using the isMobile
attribute, you can do the following in the chrome dev console:
show network conditions
, and select the option that’s available like this:
User agent
Select automatically
checkbox is not ticked.User agent
Select automatically
checkbox.The example below shows a flow which prints out if a user is on a mobile device, the chrome console is setup to use an iPhone: