---
title: "Action: send a message to Slack"
description: "Post to Slack automatically when an event happens in Guardian."
product: "Guardian"
edition: "Classic"
type: "workflow"
url: "https://docs.cloudhouse.com/guardian/classic/control/events/actions/send-a-slack-message/"
---
# Action: send a message to Slack

Post to Slack automatically when an event happens in Guardian. For example, with a Slack integration, you could trigger a Slack message to be sent in the event of a failed scan. You can configure this as an **Action** that automatically sends a Slack message every time a scan fails in your Guardian instance.

Applies to: `Guardian Classic`

!!! note

    The following process assumes you have a Slack integration already configured in Guardian. For more information, see [Slack Integration](https://docs.cloudhouse.com/guardian/classic/control/integrations/slack-integration/index.md).

![Screenshot showing the Add Action page for sending a Slack Message in Guardian.](https://docs.cloudhouse.com/guardian/classic/assets/images/guardian/control/events/slack-overview.png)

!!! tip

    For an overview of actions in Guardian, including more options available to choose from, see [Actions](https://docs.cloudhouse.com/guardian/classic/control/events/actions/actions/index.md).

## Action Settings

When configuring a **Send a Message to Slack** action, the following settings are presented:

**Action Name** field
:   A unique name for the action. This name is how you will identify this action among all others configured in your Guardian instance, so ensure it is descriptive. For example, 'New Policy Failure Message' and not simply 'Send a Message'.

**Slack Integration** drop-down
:   A list of all Slack integrations configured in your Guardian instance.  When configuring a Slack integration, you designate a specific Slack channel for that integration. From the drop-down list, select the Slack channel where you want your triggered messages to be sent.

**Message** field
:   The content to include in messages sent by this action. To make your messages dynamic, you can include variables in this field.  Variables are pieces of text that Guardian will replace with relevant data. For example, you could use the variable `{{ timestamp }}` to include the time that the action was triggered. Or, you could use the variable `{{ success }}` here to indicate whether a policy was passed or failed.

**Icon Type** drop-down
:   Slack messages sent by Guardian have an icon in place of a Slack user's profile picture.    You can select from the following icon types:

    - URL** – Displays the **Icon URL** field where you can enter the URL that leads to the icon you want to use.
    - Emoji – Displays the Emoji field where you can enter the emoji code for the icon you want to use.

    For more information on each icon type, see their respective descriptions below.

**Icon URL** field
:   The URL leading to the icon you want to use for your messages. This URL must lead to a .png file.

**Emoji** field
:   The emoji code of the icon you want to use for your messages. Emoji codes are strings of text enclosed in colons that Slack interprets as emojis. For example, entering `:red_circle:` here results in  as the icon in the above example. You can find codes for each emoji in your Slack emoji menu.

These settings are configured when adding a new action, and they can also be edited at any time through the **Actions** tab (**Control** > **Events** > **Action**). To edit an action from the **Actions** tab, click the **Ellipsis** (![Ellipses](https://docs.cloudhouse.com/guardian/classic/assets/images/guardian/buttons/ellipses.png)) and select **Edit**. Once you have made your edits, click **Done** to save them.

## Add a send a message to Slack action

You can add a new **Send a Message to Slack** action from any saved view in your Guardian instance. Each saved view represents a specific event determined using a query on the **Events** page. The saved view you select during this configuration determines the corresponding event that triggers your new action. For more information, see [Saved Views](https://docs.cloudhouse.com/guardian/classic/control/events/events/index.md#saved-views).

To add a Send a Message to Slack action, complete the following process:

!!! tip

    For help completing any of the following fields, refer to their respective descriptions in the **Action Settings** table above.

1. Navigate to the **Events** tab (**Control** > **Events**).
2. Click the **Saved Views** button at the top of the page. The **Saved Views** side panel is displayed.

    ![Screenshot showing the Guardian Events page with a border around the Saved Views button.](https://docs.cloudhouse.com/guardian/classic/assets/images/guardian/control/events/add-action-01.png)

3. Select the event you want to trigger your new action. The saved view for that event is displayed.
4. Click the **Actions** tab to display all existing actions configured for this event.
5. Click the **Add Action** button. The **Add New Action** page is displayed.

    ![Screenshot showing the Guardian Events page with a border around the Actions tab and the Add Action button.](https://docs.cloudhouse.com/guardian/classic/assets/images/guardian/control/events/add-action-02.png)

6. Click **Send a Message to Slack**. The required fields are displayed.
7. Enter an **Action Name**.
8. Select an integration from the **Slack Integration** drop-down.
9. Enter a **Message**.

    !!! tip

        Once you have entered a message, you can view a preview of the message that will be sent as part of this action. You can use this preview to test any variables you may have used. To view a sample message, click **Preview**.

    ![Screenshot showing the Add Action page for sending a Slack message with a border around the message Preview button.](https://docs.cloudhouse.com/guardian/classic/assets/images/guardian/control/events/slack-preview.png)

10. Select an **Icon Type** from the drop-down. The URL or Emoji field is displayed based on your selection.
11. Enter the **URL** or **Emoji** code.
12. Click **Done**.

Now, a confirmation dialog is displayed and you are redirected to the **Actions** tab for your selected saved view. Here, you can view your new action. To disable, edit, or test the action, click the **Ellipsis** (![Ellipses](https://docs.cloudhouse.com/guardian/classic/assets/images/guardian/buttons/ellipses.png)) and select the appropriate option.
