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 the payload of a text message. Card and IBAN numbers are masked when maskCreditCardNumbers is enabled, and US social security numbers written with hyphens or spaces when maskSocialSecurityNumbers is enabled. context is 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.
sourceactiondataWhen
welcome_screentrack_orderorderNumber, name and email, each when the form shows that fieldThe customer submits the Where is my order? form.
welcome_screentrack_orderEmptyThe customer taps the one-tap Track your orders card.
welcome_screenproduct_enquirytitle, and productId if availableThe customer taps the ask button on the current product card.
welcome_screenproduct_enquiryname, and url and price if setThe customer taps a featured product, when openProductPage is not enabled.
welcome_screenquestionEmptyThe customer taps a popular question.
welcome_screenfree_textEmptyThe customer types a message into the welcome screen input.
intro_bannerquestionEmptyThe customer taps an intro banner button.
intro_bannerfree_textEmptyThe customer types the first message below the intro banner.
shopping_agent_chatquestionproductName, if setThe customer selects a suggested prompt in the Embedded Chat widget.
shopping_agent_chatfree_textproductName, if setThe customer types a question into the Embedded Chat widget.
shopping_agent_promptsquestionproductName, if setThe customer selects a suggested question in the Embedded Prompts widget.
shopping_agent_promptsfree_textproductName, if setThe customer types a question into the Embedded Prompts widget.
buttonquestionproductName, if setThe customer clicks a button in the Button app.
ask_aiproduct_enquiryproductName, if setThe customer clicks the Ask AI tab, floating button or button.
ai_tabproduct_enquiryproductName, if setThe customer clicks the AI Tab.
ask_barfree_texturlThe customer types a question into the Ask Bar widget.
bannerquestionurlThe 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:

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.


Did this page help you?