Simple Text Messages

This section describes how to create simple messages that appear inline as if typed by a user. For how you can construct more complex messages that generate cards in the chat, see card messages.

Basic unformatted messages

Any message in Hangouts Chat is represented as a JSON object. A basic message that specifies just a simple plaintext body could look like the following:

{
  "text": "Your pizza delivery is here!"
}

If posted into Hangouts Chat (e.g. via incoming webhooks), it would look like the following:

Using formatted text in messages

Hangouts Chat lets 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~ hello
Monospace ` (backquote) `hello` hello
Monospace block ``` (three backquotes) ```
Hello
World
```
Hello
World

For example, consider the following JSON:

{
  "text": "Your pizza delivery *has arrived*!\nThank you for using _Pizza Bot!_"
}

This places a message like this into the chat room:

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.

If you include a plain link URL in your message text, such as http://example.com/foo, Hangouts Chat uses this as the link text and automatically hyperlinks that text to the specified URL.

To provide alternate link text for your link, use the following syntax:

Syntax Rendering
<https://example.com/foo|my link text> my link text

The pipe and link text are optional, so that <https://example.com/foo> and https://example.com/foo are equivalent.

Messages that @mention specific users

A bot can @mention a user in a message, providing the user ID in the following syntax:

<users/USER_ID>

This string will be substituted with an @mention of the specified user. For example, consider the following JSON:

{
    "text": "Hey <users/123456789012345678901>! Thank you for using _Pizza bot!_"
}

This payload would produce a result like the following:

Messages that @mention all users

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

{
    "text": "Important message for <users/all>: Code freeze starts at midnight tonight!"
}

Send feedback about...

Hangouts Chat API
Hangouts Chat API
Need help? Visit our support page.