Message Markup
OpenDialog message markup
As outlined, within the 'Message' section under 'Working with OpenDialog', we currently support a few of the message types through the message editor UI and we are continually adding more and more UI widgets. However, we do support a wider full list of messages which can be added via 'Custom Message'.
In OpenDialog the aim for message markup is to provide a single way of writing messages that will then be automatically translated into the appropriate format for the frontend platform that should receive and transmit the message to the user.
We use a custom XML style markup language for describing message templates. Not all message platforms support all message types, so in some cases the resulting message will differ between platforms. A full explanation of the XML structure for each message type can be seen below.

Custom Message Types

Text Message

A plain message with only text. Specially formatted links can also be included in the text body
1
<message>
2
<text-message>{message-text}</text-message>
3
</message>
Copied!
Example:
1
<message>
2
<text-message>
3
Hello, this is a text message.
4
</text-message>
5
</message>
6
Copied!
Messages can also contain URLs in the text - that will be linkified. Links like greenshootlabs.com in the message text will be turned to links.
1
<message>
2
<text-message>
3
You can have a link straing in text like this: hey go to greenshootlabs.com or you can do this:
4
</text-message>
5
</message>
Copied!
There is no support at the moment for any other formatting such as bold, italics etc

Image Messages

Displays an image message. Optionally, the image can also be a link that can optionally open in a new tab if the url property is included.
1
<message>
2
<image-message>
3
<src>{img_src}</src>
4
<url new_tab="{true|false}">{url}</url>
5
</image-message>
6
</message>
Copied!
Example
1
<message>
2
<image-message>
3
<src>https://docs.opendialog.ai/img/od-logo-with-credit.jpg</src>
4
<url new_tab="true">https://docs.opendialog.ai</url>
5
</image-message>
6
</message
Copied!

Button Messages

Button messages allow you to provide the user a number of options to select as a response. The basic mark up is:
1
<message>
2
<button-message clear_after_interaction="true|false">
3
<text>{button message text}</text>
4
<external>true|false</external>
5
</button-message>
6
</message>
Copied!
Setting the external property to true results in the message buttons appearing outside of the button message (this defaults to false if not set).
NB
Button messages with external buttons must be the last message in the intent so they aren't overwritten by any subsequent message in the webchat view.
Setting the clear_after_interaction property to false means that the buttons will remain visible to the user after being interacted with

Buttons

A button message can contain 1 or more buttons for the user to interact with (some platforms have different restrictions on the number of buttons per message) Each button must define a text element to specify the text that should be shown to the user.
OpenDialog has built in support for 4 types of button:

1. Callback buttons

Callback buttons will send a callback_id (and optionally a value) when interacted with by the user that will move the conversation forward. Make sure that any callback_id you use in a button response is mapped to an intent in the interpreter engine config.
1
<button>
2
<text>Callback Button</text>
3
<callback>callback id</callback>
4
<value>attribute_name.attribute_value</value>
5
</button>
Copied!
Values can be optionally set on callback buttons to add some extra context to the button response. The format of button values is:
1
attribute_name.attribute_value
Copied!
where attribute_name should be the ID of an attribute that has already been defined in the system.
When passing through the Callback Interpreter, button values will be parsed and an attribute will be returned with the value set as per the button
Example
Here is are examples of a message with one button and two buttons. Clicking on the button would cause that callback value to be sent back to OpenDialog which could then be matched with an incoming intent.
1
2
<message>
3
<button-message>
4
<text> A bit of explainer text at the top </text>
5
<button>
6
<text>Click me!</text>
7
<callback>intent.app.startAConversations</callback>
8
</button>
9
</button-message>
10
</message>
Copied!
1
2
<message>
3
<button-message>
4
<text> A bit of explainer text at the top </text>
5
<button>
6
<text>Click me!</text>
7
<callback>intent.app.startAConversations</callback>
8
</button>
9
<button>
10
<text>Or click me!</text>
11
<callback>intent.app.startADifferentConversations</callback>
12
</button>
13
</button-message>
14
</message>
Copied!
Links buttons are used to create links to other web pages. The new_tab property can be set to true to force the links to open in a new tab. If not set, links default to opening in the same tab
1
<button>
2
<text>Link Button</text>
3
<link new_tab="true"|"false">http://example.com</link>
4
</button>
Copied!
Example
1
<message>
2
<button-message>
3
<text> Here are some very useful resources for you. </text>
4
<button>
5
<text>Wikipedia</text>
6
<link new_tab="true">https://wikipedia.org</link>
7
</button>
8
<button>
9
<text>W3C</text>
10
<link new_tab="true">https://w3.org.org</link>
11
</button>
12
</button-message>
13
</message>
Copied!

3. Click to Call buttons

Click to call buttons are used to create buttons for telephone numbers. They created a standard format tel: link that depending on the user's current device and platform will start a phone call to the number given
1
<button>
2
<text>CLick to Call</text>
3
<click_to_call>02079460000</click_to_call>
4
</button>
Copied!

4. Tab Switch buttons

Tab Switch buttons should only be used for the OD Webchat platform in conjunction with comments and indicates that the button should switch the user to the 'comments' tab
1
<button>
2
<text>Tab Switch</text>
3
<tab_switch>true</tab_switch>
4
</button>
Copied!

Button Types

Buttons can be defined with a type that can affect how they are displayed as a button on screen. Types are added as properties of the button like this:
1
<button type="{type}">
2
<text>Click me!</text>
3
<callback>intent.app.startAConversations</callback>
4
</button>
Copied!
There are currently 2 types that can be used:
    skip - If a button in an external button message has type of skip, it will appear below the other buttons with a different appearance. This can be used in conjunction with other messages to allow a user to skip past an intent
    inline - If a button in a standard button message (not external) has a type of inline, it will appear along with the button message text, inside the chat bubble.

Rich messages

Rich messages allow for more control around message content and how it is displayed to the user. They can be thought of like 'card' style messages and contain any of the following elements in combination:
    Title
    Subtitle
    Text
    Image
    Buttons
Where buttons can be any of the buttons described above.
1
<rich-message>
2
<title>Title</title>
3
<subtitle>Subtitle</subtitle>
4
<text>Text</text>
5
<image>
6
<src>image_src</src>
7
<url new_tab="true|false">www.example.com</url>
8
</image>
9
</rich-message>
Copied!
Example
1
<rich-message>
2
<title>Rich Message</title>
3
<subtitle>With a subtitle</subtitle>
4
<text>Some engaging text</text>
5
<image>
6
<src>https://docs.opendialog.ai/img/od-logo-with-credit.jpg</src>
7
<url new_tab="true">https://docs.opendialog.ai</url>
8
</image>
9
</rich-message>
Copied!

Form messages

Form messages allow for user to input data in standard web form rather than text entry. When submitted, the values entered by the user are sent back along with the defined callback. All form messages must contain the following elements:
1
<form-message>
2
<text>Text</text>
3
<submit_text>Submit Text</submit_text>
4
<callback>Callback</callback>
5
<auto_submit>true|false</auto_submit>
6
</form-message>
Copied!
Here, the text value is shown at the top of the form message and the submit_text value is shown on the form submit button. When auto_submit is set to true, the form will automatically be submitted when the user selects a value. This works best when just 1 element is added to the form
Elements
Form messages have support for a number of different elements (matching what is possible in a standard HTML form). All elements are defined in the same way, and there is no limit to how many can appear on a form message.
Each element must define a type and display, and can optionally define required and default_value. If required is set to true, the form cannot be submitted unless the field has a value.
1
<element>
2
<element_type>textarea|text|number|email|select|auto_complete_select|radio</element_type>
3
<display>Display Name</display>
4
<required>true|false</required>
5
<default_value>Default Value</default_value>
6
</element>
Copied!
When using radio or select elements, you must define an options block giving the options to be presented in the radio list or select element:
1
<element>
2
<options>
3
<option>
4
<key>Key</key>
5
<value>Value</value>
6
</option>
7
</options>
8
</element>
Copied!
The email element type acts just like a text element, but on submission, is validated to ensure it is formatted like an email address
This form message example was created with the following XML:
1
<message>
2
<form-message>
3
<text>Text</text>
4
<submit_text>Submit Text</submit_text>
5
<callback>Callback</callback>
6
<auto_submit>false</auto_submit>
7
8
<element>
9
<element_type>select</element_type>
10
<name>title</name>
11
<display>Title</display>
12
<options>
13
<option>
14
<key>mr</key>
15
<value>Mr.</value>
16
</option>
17
<option>
18
<key>mrs</key>
19
<value>Mrs.</value>
20
</option>
21
<option>
22
<key>other</key>
23
<value>Other</value>
24
</option>
25
</options>
26
</element>
27
28
<element>
29
<element_type>text</element_type>
30
<name>name</name>
31
<display>Name</display>
32
</element>
33
34
</form-message>
35
</message>
Copied!

Empty Messages

This is needed so an intent can have a matching template that doesn't result in a message being sent to the user. This may not be supported on all platforms. Empty messages can be useful to add to intents that we want to match for a user, but only send a message if certain conditions are met - for example using the standard intent.core.welcome to only send a message if the user was seen more than once.
1
<empty-message/>
Copied!

List messages

List messages allow for multiple messages to be combined into a single message for the user that is displayed as a carousel that users can scroll between. These are good for displaying multiple search results or related items.
List messages work well together with rich messages but can be used as a wrapper for any messages types.
The only option available for list messages is view-type. This can either be vertical (default) or horizontal
Note - messages with very different sizes may not display well in a horizontal carousel
1
<list-message list_type="horizontal">
2
<item><text-message>{text_message}</text-message></item>
3
<item><image-message>{image_message}</image-message></item>
4
<item><rich-message>{rich_message}</rich-message></item>
5
</list-message>
Copied!

Input take-over messages

The following messages take over the standard user input to provide the user a different way of entering data
NB
These types of message MUST be the final message in the intent so they aren't overwritten by any subsequent message in the webchat view.

Date Picker messages

These allow the user to enter a date by selecting day, month and or year. Each of these fields can be defined as required meaning the message cannot be submitted unless the user has entered a value.
The min_date and max_date fields restrict the dates that are shown to the user so that what they submit is always within that range. The dates provided should be ISO date format containing at least the year, or just the word today.
1
<date-picker-message>
2
<text>{message text}</text>
3
<callback>{callback}</callback>
4
<attribute_name>{attribute name}</attribute_name>
5
<submit_text>{submit text}</submit_text>
6
<day_required>true|false</day_required>
7
<month_required>true|false</month_required>
8
<year_required>true|false</year_required>
9
<max_date>today|yyyy-mm-dd|yyyy-mm|yyyy</max_date>
10
<min_date>today|yyyy-mm-dd|yyyy-mm|yyyy</min_date>
11
</date-picker-message>
Copied!

Autocomplete message

The autocomplete message is used to create an input that will offer suggestions to a user as they start typing. This message is supported by an API that should accept a query string and respond with an array of items to show in the JSON format below:
1
[
2
{
3
"name": "item1"
4
},
5
{
6
"name": "item2"
7
},
8
{
9
...
10
}
11
]
Copied!
The message XML accepts a number of options that help the webchat component know how to construct the query to send to the API:
    options-endpoint.url - The URL of the API to hit. This can be relative or absolute. It is often a good idea to create a local API proxy route in your OD application to be able to format responses from external sources.
    options-endpoint.params - Each param in here will be added to the API url as query parameters in the format ?{name}={value}.
    options-endpoint.query-param-name - This field specifies the name to be used for the query query param. The value of the query param will be all characters that the user has started typing in the auto-complete box.
So in the example below, each time the user entered a character into the input field, the following GET request would is made to fetch the next set of suggestions
1
/api/v4/products?name=value&query={}
Copied!
There are 2 text type fields text which will appear when the message starts showing and placeholder which shows in the message input box before a user starts typing
1
<autocomplete-message>
2
<title>{text}</title>
3
<callback>{callback}</callback>
4
<submit_text>Submit</submit_text>
5
<options-endpoint>
6
<url>/api/v4/products</url>
7
<params>
8
<param name="name" value="value" />
9
</params>
10
<query-param-name>query</query-param-name>
11
</options-endpoint>
12
<attribute_name>ProductName</attribute_name>
13
<placeholder>Start typing</placeholder>
14
</autocomplete-message>
Copied!
Autocomplete closed
Autocomplete With Suggestions

Full page messages

Rich and Form messages can also be presented as 'full page' messages. When full page messages are received, they will take over the entire chatbot screen (depending on what is supported by each platform). For webchat full page messages, the user input is also taken over.
NB
These types of message MUST be the final message in the intent so they aren't overwritten by any subsequent message in the webchat view.

Full Page Rich messages

Full page rich messages are defined in exactly the same way as standard rich messages
1
<fp-rich-message>
2
<title>Title</title>
3
<subtitle>Subtitle</subtitle>
4
<text>Text</text>
5
<image>
6
<src>image_src</src>
7
<url new_tab="true|false">www.example.com</url>
8
</image>
9
</fp-rich-message>
Copied!

Full Page Form messages

Full Page Form messages are defined in exactly the same way as form messages, but with a different element name.
Optionally, the full page form message can contain a cancel button. This allows the user to tell the bot they do not want to submit the form. When clicked, the value of cancel_callback is sent. The cancel button can be added to a form message with the following mark up:
1
<fp-form-message>
2
<text>Text</text>
3
<submit_text>Submit Text</submit_text>
4
<callback>Callback</callback>
5
<auto_submit>true|false</auto_submit>
6
<cancel_text>Text</cancel_text>
7
<cancel_callback>Callback</cancel_callback>
8
</fp-form-message>
Copied!

Special Messages

The messages below do not act like standard messages that appear in a message list and history, but perform specific actions.

CTA messages

CTA messages are used to display content in the minimised chatbot and will only work with the OpenDialog webchat platform. Each time a CTA message is sent, the CTA text in the minimiaed chatbot header is updated.
CTA messages can only contain text:
1
<cta-messsage>
2
{text}
3
</cta-messsaeg>
Copied!

Hand to System messages

Hand to system messages are intended to be used to inform OpenDialog that the handling of chat has been taken over by another channel (typically a human). In OpenDialog webchat, this means that new messages sent by the user are not sent to the incoming/webchat endpoint, but are handled by an external system.
Documentation for handling hand-to-human messages is being developed.
Hand to system messages contain a number of data elements that have a unique name specifying what they are for. This way, any custom data payload can be sent with hand to system messages
1
<hand-to-system-message system="my-custom-system">
2
<data name="replace_name_attribute">Value</data>
3
</hand-to-system-message>
Copied!

Meta messages

Meta messages are designed to allow the incoming message to have an effect on the conversational interface. There are a number of directives. Each meta message is made up of a number of data attributes defined as below:
1
<meta-message>
2
<data name="textLimit">50</data>
3
<data name="progressPercent">10</data>
4
<data name="progressText">Getting Started</data>
5
</meta-message>
Copied!
The supported data attributes at the moment are:
    textLimit - imposes a limit on the text input to only allow a user to enter a capped number of characters
    progressPercent - updates the progress bar at the top of the webchat bot to the percentage provided
    progressText - updates the progress bar text at the top of the webchat bot to the value provided
    teamName - Updates the current team name of the bot
Meta Messages can be placed anywhere in a message template and will have the same effect

Attribute messages

Attribute messages takes the name of a context and attribute and expects the value of the attribute to be properly formed XML. The content of that XML will then be rendered as a message.
1
<attribute-message>
2
context_name.attribute_name
3
</attribute-message>
Copied!
You might look to use this if you are using an external service and wanted control over the formatting of the resulting message.
Last modified 13d ago