Predefined message
Messages sent from the welcome screen, the intro banner, the Button app, or the Embedded Chat, Embedded Prompts, Ask AI, AI Tab, Ask Bar and Banner widgets are sent as a predefinedMessage instead of a text message. As well as the text, it tells the flow where the message was sent from and what the customer chose, so the flow can branch on fixed values instead of on the wording of a message. The Track Order widgets are not affected and still send their own track_order event.
A predefined message can open a conversation or arrive in one that's already in progress, for example when the customer clicks an intro banner button or the Ask AI tab after chatting for a while. Messages the customer types into the chat are sent as normal message events, as are the Embedded Chat widget's questions after the first.
The customer sees no difference: the text appears as their message, including after a page reload and in other tabs.
{
"from": "customer",
"type": "predefinedMessage",
"payload": "Where is my order A-2847?",
"context": {
"source": "welcome_screen",
"action": "track_order",
"data": { "orderNumber": "A-2847", "email": "[email protected]" }
}
}payload- the text shown as the customer's message, such as the question they tapped or the message they typed. It's a string, the same as thepayloadof a text message. Card and IBAN numbers are masked whenmaskCreditCardNumbersis enabled, and US social security numbers written with hyphens or spaces whenmaskSocialSecurityNumbersis enabled.contextis not masked.context.source- where the message was sent from. One of the fixed values in the table below.context.action- what the customer chose to do. One of the fixed values in the table below.context.data- extra details, such as an order number. Always an object, which is empty when there is nothing to add. All values are strings.
source | action | data | When |
|---|---|---|---|
welcome_screen | track_order | orderNumber, name and email, each when the form shows that field | The customer submits the Where is my order? form. |
welcome_screen | track_order | Empty | The customer taps the one-tap Track your orders card. |
welcome_screen | product_enquiry | title, and productId if available | The customer taps the ask button on the current product card. |
welcome_screen | product_enquiry | name, and url and price if set | The customer taps a featured product, when openProductPage is not enabled. |
welcome_screen | question | Empty | The customer taps a popular question. |
welcome_screen | free_text | Empty | The customer types a message into the welcome screen input. |
intro_banner | question | Empty | The customer taps an intro banner button. |
intro_banner | free_text | Empty | The customer types the first message below the intro banner. |
shopping_agent_chat | question | productName, if set | The customer selects a suggested prompt in the Embedded Chat widget. |
shopping_agent_chat | free_text | productName, if set | The customer types a question into the Embedded Chat widget. |
shopping_agent_prompts | question | productName, if set | The customer selects a suggested question in the Embedded Prompts widget. |
shopping_agent_prompts | free_text | productName, if set | The customer types a question into the Embedded Prompts widget. |
button | question | productName, if set | The customer clicks a button in the Button app. |
ask_ai | product_enquiry | productName, if set | The customer clicks the Ask AI tab, floating button or button. |
ai_tab | product_enquiry | productName, if set | The customer clicks the AI Tab. |
ask_bar | free_text | url | The customer types a question into the Ask Bar widget. |
banner | question | url | The customer clicks the Banner widget. payload is the message showing in the banner. |
In your flow, check whether the message type is predefinedMessage, then branch on context.action, and on context.source where needed. Don't match on the wording of payload: it is configurable and translated, so it can change.
If a message isn't a predefinedMessage, treat it as a normal message. Its text is the same text the customer sees. A message is sent as a normal message event when it's sent by:
- a proactive button.
- your own call to
window.dgchat.methods.sendMessage.
Keep the Headless SDK Components and the Genius Chat Widget on the same version. When a component opens the chat widget and one of them was released before predefined messages were added, the message isn't sent as a predefinedMessage.
Updated 8 minutes ago
