Skip to content

Message node

Guido edited this page Jun 9, 2020 · 16 revisions

Used to send a plain text message to the chatbot's user, a handlebars-like syntax can be used to insert values from the chat context, for example:

Hi {{firstName}}, your check is {{total}} euros

Some chat context keys are automatically populated (like {{firstName}}, {{lastName}}, {{language}}, etc - if the platform provides them) , other keys are system specific and are read-only (like {{userId}}, {{chatId}} and {{transport}}), some other keys depends on the current flow, like {{payload}}, for example if the upstream node sends a payload like

{
  total: 42,
  shipping: {
    address: 'Nowhere street,
    city: 'Milan'
  }
}

can be used in the text message in this way

Your order of {{payload.total}} will be shipped to {{payload.shipping.address}}, {{payload.shipping.city}}

For more information read the chat context section.

It's possible to specify more content versions for the same message, one will we randomly chosen with an even distribution.

If a language is specified in the drop down menu, then the message will be added only if the specified language matches the one in the chat context. Most of the platform provide the user language, this value is stored in the chat context when the user starts a conversation. In order to support multiple languages in a chatbot, just chain different Message node with different languages, the ones that don't match the user language will be skipped.

Multi language support

tbd: Chain multiple messages

The text message can be passed through the payload by the upstream node:

msg.message = 'I am a message';
return msg;

or for multiple versions of the message

msg.message = [
  'First version of the message',
  'Second version of the message'
];
return msg;

Available parameters for the msg.payload

Name Type Description
message string / array of [string] String or array of strings to send. If array, a random one will be chosen
language string Language of the message
fallback string Fallback message to use in case of a message broadcast containing tokens like {{first_name}} or {{last_name}} and the bot doesn't have privileges to access profile info. Facebook
Clone this wiki locally