Using Context and Variables in Flow

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.

Intent Detection Node Example

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

Full response Example

msg :{
    payload :{
      result: {
        intent: 'intent_name',
        slots: {},
        action: {},
        fulfilment: 'message from NLP', //for a single response
        fulfillmentResponses: ['array', 'of', 'nlp', 'responses'],
        intentDetectionConfidence: 1
      }
    }
  }

BaaS API Example

When a BaaS node responds, data will be stored in a baas.[alias] object.

Example object. Note that baasAlias will be replaced with whatever aliases, you picked

  msg :{
  baas :{
    baasAlias: {
      some: 'response',
      data: 'here'
    }
  }

}

Initial Context when Conversation is started

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"
}

Example Message Payload

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"
	}
}