Supported Message formats


In later guide we learnt to build, text and deploy a simple text message bot. However Hangouts chat has much more to offer then just mere simple text messages and these are cards. In this guide, we will dive deep to format simple text messages and also learn how to use few of the cards offered by Hangouts chat on Gupshup's platform.

Simple Text Messages


1. Basic unformatted messages

A basic unformatted message is just a simple plaintext body as defined at label BasicUnformattedMessages in the below script sample.

[main]
   BasicUnformattedMessages: A basic message that specifies just a simple plaintext body

BasicUnformattedMessages
If posted into Hangouts Chat, it would look like the following:

simple text

2. Using formatted text in messages

You add basic formatting to the message text, including bold, italic, and strikethrough. To format text, wrap it with the following symbols:

FormatSymbolExampleResult
Bold**hello*hello
Italic_(underscore)_hello_hello
Strikethrough~~hello~hello
Monospace` (backquote)`hello`hello
Monospace block``` (three backquotes)```
Hello
World
```
hello
World

Let see an example:

[main]
   UsingFormattedTextInMessages:Wondering how your friend sent you a message with some text in *Bold*? Not just *Bold*, you would have      also seen some messages in _Italics_, ~Strikethrough~, `Monospace` and even ```Monospace block```

UsingFormattedTextInMessages
This places a message like this into the chat room:

formatted text

This text markup syntax is the same syntax that applies to messages typed by users, which is why it is distinct from the HTML-based formatting applied to text inside cards.

3. Messages that @mention

Your bot can @mention a user in a message, provide the user ID in the following syntax:

<users/USER_ID>

The bot messages in the scripting tool are really templates. You can create dynamic parts by enclosing the name of the part in double braces. Since USER_ID is variable, the bot developer will have to create your message accordingly.

Let's see how one can implement it in the script(default.src) file:
Consider a situation where a bot message should be “Hey @Smit! Thank you for using demo bot“, here the bot response specifies a user, named - 'Smit'. To implement this you will have to write something as shown below in the script file:

[main]
    MessagesThatMention:Hey {{specificMention}}! Thank you for using demo bot

{{specificMention}} is the variable whose value will have the @mention() syntax. To assign the value this syntax let's write a logic to extract USER_ID

cannot directly use the given syntax, you are required to write a dynamic message here This string will be substituted with an @mention of the specified user. For example,

This payload would produce a result like the following:

mention specific users

You can use the special user ID all to @mention all the users in a space. For example:

[main]
    MessagesThatMentionAll:Important message for <users/all>: Code freeze starts at midnight tonight!

MessagesThatMentionAll

mention all

Card Messages


Coming soon…