Message Templates

Some integration messages can be formatted using templates. Templates are a way to define a message using some request from the data. For example, you can define a message that includes the name of the user that triggered the message.

For example, if you have a request with a body containing name and email fields, like this curl request:

curl -X POST \
    -H "Content-Type: application/json" \
    -d '{ "name": "John Doe" }' \
    https://gclb.io/{endpointId}

You can define a message template like this in integration that supports templates (like Slack, Discord, …):

Hello, {body.name}!

That will be evaluated to:

Hello, John Doe!

Fallbacks

If the field is not present in the request, the template will be evaluated to an empty string. If you want to provide a fallback value, you can use the ?? (js nullish coalescing) operator:

Hello, {body.name ?? "stranger"}!

That will be evaluated to the following if the name field is not present in the request:

Hello, stranger!

Fallbacks syntax

The fallback value can either be wrapped in double quotes, single quotes or nothing at all. The following are all valid:

Hello, {body.name ?? "stranger"}!
Hello, {body.name ?? 'stranger'}!
Hello, {body.name ?? stranger}!