> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refold.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Building a Slack integration

> This tutorial will give an example of how to create a Slack integration that sends message from your app to the Linked Account's Slack.

## Pre-requisites

1. Slack App is enabled in Refold.
2. Slack OAuth app credentials added to Refold. Refer [here](https://docs.gocobalt.io/resources/integration-providers/slack#creating-an-app-in-slack).
3. Trigger created in Refold. Refer [here](https://docs.gocobalt.io/guides/workflow/triggers).
4. Linked Account available. Refer [here](https://docs.gocobalt.io/guides/platform/linked-account).

## Building a Workflow

#### 1. Create Workflow in app

* Go to your [`Apps catalog`](https://app.gocobalt.io/apps) in **Refold** > Search for `Slack` > `Workflows` > `Add Workflow` > Choose `Manually` > Give it a name and click on `Add Workflow`.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Slack/Slack_workflow.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=1d3c7b105087c1830c1b3aa848edc57e" alt="Navigation for Workflow setup" data-path="images/Slack/Slack_workflow.png" />

#### 2. Adding the Trigger

To add a trigger for a Workflow in Refold, you need to select details about the Trigger like the Type and which trigger to be implemented.

To add a Trigger, follow these steps:

* Click on the **Start node** to add a trigger.
* In the right side, select the **Type** and the **Trigger** and click on the `Add Trigger` button.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Slack/Slack_start.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=d0696421b89a770e3f1e4cc575cf9668" alt="Start Node Trigger" data-path="images/Slack/Slack_start.png" />

#### 3. Adding the Slack Action

* From `Actions`, add a Slack node to the workflow.
* Click on the node and select an Action from the `Choose an Action` dropdown menu.
* Since we will send a message to a channel or a user through the action, provide a `User or Channel ID` and click on `Save`.

<img height="200" src="https://mintcdn.com/cobalt-55/6ZvwOHqAhmVnIyqF/images/Slack/Slack_action.png?fit=max&auto=format&n=6ZvwOHqAhmVnIyqF&q=85&s=5e9efe9c9579721d53be391c15ebde3a" alt="Slack Node" data-path="images/Slack/Slack_action.png" />

<Warning>
  Before clicking on `Save`, make sure that you have entered data for all the mandatory fields whichever required.
</Warning>

* Connect the two nodes by clicking on `+` button on the `Start` node and dragging the arrow to the **Slack** node.

#### 4. Publishing the Workflow

* To publish the workflow, click on the `Publish` button in the top, **Select Environments** of the Workflow and click on `Publish`.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Slack/Slack_publish.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=994ee7c7ae9c1a95f1deb8dbba35172f" alt="Publish Workflow" data-path="images/Slack/Slack_publish.png" />

## Enabling the Workflow

To enable a workflow, end user or a Linked Account needs to Toggle On the Workflow after connecting with the application.

* Navigate to the Linked Account in which the Workflow needs to be enabled by getting its' **Hosted URL**.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Slack/Slack_linked.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=99b8486c82e3acc53fac043de180e154" alt="Navigate to Linked Account" data-path="images/Slack/Slack_linked.png" />

* Go to the Hosted URL and select **Slack** from `Manage your Integrations` list.
* Click on the `Connect` button, review the permissions and allow them for a successful connection.
* After a successful connection, you can see the `Configure` section in the Slack Application page.
* Enable the Workflow **Send Message** by turning the **toggle On** and click on `Save`.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Slack/Slack_enable.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=1e412982dc5a41a54fa6b5f72da70fd4" alt="Enable Workflow in Linked Account" data-path="images/Slack/Slack_enable.png" />

## Fire an App Event

Lastly, we'll fire an App Event whenever a contact is created in your app by using the Workflow.

* Navigate to `Try API` in **Refold**.
* Choose the **Linked Account** created to test the workflow, select the **Event** and Slack as the **Application**.
* Click on the `Fire Event` button in the top right.

<img height="200" src="https://mintcdn.com/cobalt-55/z_Cm6DgpvP5zfZT8/images/Slack/Slack_fire.png?fit=max&auto=format&n=z_Cm6DgpvP5zfZT8&q=85&s=12d60e1d1b11e808c1eead5f33766e5d" alt="Fire an App Event" data-path="images/Slack/Slack_fire.png" />

* You can check the status of the event by navigating to `Logs` > `Events` in **Refold**.

Congratulations! We have successfully built a Slack integration that sends message from your app to the Linked Account's Slack.
