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.
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
If posted into Hangouts Chat, it would look like the following:
You add basic formatting to the message text, including bold, italic, and strikethrough. To format text, wrap it with the following symbols:
Format | Symbol | Example | Result |
---|---|---|---|
Bold | * | *hello* | hello |
Italic | _(underscore) | _hello_ | hello |
Strikethrough | ~ | ~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```
This places a message like this into the chat room:
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(
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:
[main]
MessagesThatMentionAll:Important message for <users/all>: Code freeze starts at midnight tonight!
Coming soon…