Source: https://gitlab-test-org.docs.pageloop.ai/template-creation-slack

# Slack Templates

When you add the **Slack** channel to a template, the **Create your Slack Template** screen opens. The Preview on the right shows how the message looks in Slack.

![](assets/slackcreate-v-2-editor.png)

## Add the content

Under **Content**, choose how you want to write the message body.

#### Text

Use **Text** to send a simple message. Type your message and use the toolbar above the field for bold, italic, strikethrough and code formatting. You can add placeholders within `{{ }}`.

#### JSON

Use **JSON** to send a message built with Slack's Block Kit.

![](assets/slackcreate-v-2-json.png)

1. Design your message in the [Slack Block Kit Builder](https://app.slack.com/block-kit-builder).
2. Copy the JSON blocks array, from the opening `[` to the closing `]`, as shown below.

   ![](assets/template-slack-json.png)
3. Paste it in the **JSON** tab in Fyno.

> [!WARNING]
>
> Handlebars do not work in Slack's Block Kit Builder.

## Additional Configuration (optional)

Expand **Additional Configuration** to group related notifications into a Slack thread.

| Field       | What it does                                                                                                                                                                                     |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Tag ID**  | A unique identifier or placeholder used to create a thread. All consecutive notification events that use the same identifier are added to the same thread.                                       |
| **Tag TTL** | The time period (a numeric value or a placeholder) for which this Tag ID is valid. Enter the value in the first field, and select **Seconds**, **Minutes**, **Hours** or **Days** in the second. |

## Placeholders

Below the **Channels** section on the left, you can find placeholders. Placeholders are denoted by **`{{ }}`** or **Handlebars**. Click a placeholder to open a pop-up window where you can define its parameters. See the comprehensive guide on [Handlebars](https://handlebarsjs.com/guide/).

> [!TIP]
>
> **Did you know?**
>
> You can use a period (.), underscore (\_) or hyphen (-) within the handlebars. Try it now!

> [!WARNING]
>
> You cannot use only numeric values as placeholder keys.

## How to tag users and channels

Use these in your message content:

| Syntax        | Who it notifies                                                                                    |
| ------------- | -------------------------------------------------------------------------------------------------- |
| `<!here>`     | Only the active members of a channel.                                                              |
| `<!channel>`  | All members of a channel, active or not.                                                           |
| `<!everyone>` | Every person in the #general channel, which is every non-guest member of the workspace.            |
| `<@abc.xyz>`  | A specific user. For example, use `<@abc.xyz>` to tag the user with the email `abc.xyz@gmail.com`. |

## How to add dynamic content

You can add dynamic content to your templates using one of the four options below:

- [Placeholders](./template-dynamic-content#placeholders)
- [System Variables](./template-dynamic-content#system-variables)
- [Handlebars](./template-dynamic-content#handlebars)
- [Components](./template-dynamic-content#components)

## How to test a Slack template

Use this feature to test a template thoroughly before including it in any Notification Event. This ensures early detection and resolution of any potential issues, for a seamless user experience.

1. Click **Run Test** at the top right of the template. The test pop-up opens.

   ![](assets/template-slack-test.png)
2. Enter the Slack recipient, or a `distinct_id`. **Make sure to enter the distinct\_id of a Test User profile.**
   - To send a direct message, use `@name`.
   - To send a message to a channel, use `#channel_name`. Make sure the Slack app you created is added to that channel.
3. Select a Slack integration that is already configured in Fyno.
4. Click **Test** to send the message to the recipient with the selected integration. You see the success or failure message along with a link to the Sent Logs.

## Save and go live

Click **Save** to save the template as a **Test** version. You can save different versions of the template this way. Use **Go Live** when you are ready to move your template to the **Live** version.

> [!NOTE]
>
> If your workspace has a maker-checker workflow enabled for template management, **Go Live** needs an additional approval step. Choose from your designated approvers, who review and authorize the template changes. See [Approval flow](./approval-flow) for the steps.
