How to Create Standup Bot Using Conductor-Slack Integration
Tags: microservices, slack, orchestration, automation
Published: 2023-07-07 08:28:02

Slack, the popular workplace communication platform, is winning hearts worldwide. However, its usage shouldn’t be limited to communications alone. There is more you can do with powerful integrations with other applications.

We used our product, “Orkes Conductor,” to automate our daily tasks in Slack. At Orkes, we solved two of our biggest challenges. We created our engineering teams' standup bot & our community channel’s welcome message through effective Slack integrations using Orkes Conductor.

In this blog post, we’ll have a walkthrough on how you can create a standup bot for posting daily updates on a Slack channel using Orkes Conductor. Orkes Conductor is a powerful orchestration platform for building distributed applications that makes it easy to incorporate integrations such as Slack in your applications seamlessly.

## Creating Standup Bot

Let’s see how Orkes Conductor can be leveraged to build your standup bot.

Here is the overview of our standup bot:

- The workflow is kicked off at a specific time (e.g., 10 AM) on weekdays.
- The workflow sends a personalized message to each team member to provide an update.
- Users provide an update to the bot.
- The workflow waits for all the updates to arrive and waits for a specific time (e.g., 3 hours).
- Once all the updates are given, or the timeout occurs, all the updates are collected and posted to a shared team channel.

Boom! You’re done with the updates! 🤖

No more messing up with wrong channels; and the managers need not worry about missing the updates.

Let’s have a sneak peek at the most essential steps in building your Standup bot.

1. Create a Workflow, Webhook & Scheduler in Orkes Conductor
2. Create a Slack App to be integrated with your organization’s Slack Account

## Creating Workflow

Let’s visualize the workflow.

![Standup Bot Workflow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9cer4icut8t1cr4qkhe.png)

[View in Playground](https://play.orkes.io/workflowDef/standup_updates_main/1)

You can get the JSON file for the workflow [here](https://github.com/conductor-sdk/conductor-examples/blob/main/standup-bot/standup_updates_main.json).

In this example, we have 2 users. They are the forks of a [fork-join](https://orkes.io/content/reference-docs/operators/fork-join) task. These forks run in parallel to complete the workflow. For each individual, a fork is to be added, where each fork includes a [sub-workflow](https://orkes.io/content/reference-docs/operators/sub-workflow), which is nothing but incorporating another workflow within your main workflow.

Here’s how the workflow added as sub-workflow (**individual_updates**) looks like:

![Individual Updates Workflow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6110bgpj22hvdnkitnl4.png)

[View in Playground](https://play.orkes.io/workflowDef/individual_updates)

You can get the JSON file for the workflow [here](https://github.com/conductor-sdk/conductor-examples/blob/main/standup-bot/individual_updates.json).

When the main workflow is run, all the forks execute in parallel. So let’s see how each of the individual updates is processed.

- The workflow begins with an [HTTP task](https://orkes.io/content/reference-docs/system-tasks/http) (**send_welcome_message**) that sends a welcome message to the user asking for daily updates.

You can specify the Slack account’s token as secret so that your confidential data is not exposed within the workflow definitions.
`workflow.secrets.slack_standup_token`

- It is followed by a [do-while task](https://orkes.io/content/reference-docs/operators/do-while) (**loopTask)** that captures the user inputs. The loop condition is checked based on the [webhook task](https://orkes.io/content/reference-docs/system-tasks/wait-for-webhook) (**webhook_tas**k), which captures incoming events from Slack.

For the webhook task, you need to create a Webhook inside Conductor that can listen to events from Slack.

- A series of [JSON JQ Transform tasks](https://orkes.io/content/reference-docs/system-tasks/jq-transform), then follow it.

1. **jq_aggregate_updates** - Used to aggregate updates from the user.
2. **jq_convert_to_string** - Used to convert the updates into CSV format.
3. **append_user_name** - Used to append the user name with updates.

- The final output is posted to the Slack channel using an HTTP task (**post_updates**).
Specify the Slack channel where the update is to be posted. You can save the Slack channel name as a secret in Orkes Conductor so that your confidential data is not exposed within your workflow definition.
`workflow.secrets.slack_conductor_channel_url`

You can add the above workflow as sub-workflows in the fork-join tasks depending on the number of employees in your team.

In addition, you can configure the main workflow so that all the sub-workflows added as forks can be marked as **_optional_** so that the workflow can complete without waiting for all the forks. This comes into use when employees are OOO, so their updates won’t be available.

If you want to collect all the updates within a certain time, such as, let’s say, within 3 hours, you can add a [timeout](https://orkes.io/content/reference-docs/api/metadata/creating-workflow-definitions#:~:text=user%E2%80%99s%20email%20address.-,timeoutSeconds,-Time%20(in%20seconds)) for the **_individual_updates_** workflow of 10,800 seconds.

## Creating Webhooks

You have seen that a webhook task is utilized to collect user updates. You need to [create a Webhook](https://orkes.io/content/reference-docs/system-tasks/wait-for-webhook#creating-webhook) inside Orkes Conductor by navigating to the **Webhooks** option from the left menu and choosing the platform as “Slack”. Choose the standup bot workflows created in the previous step. Now, a Webhook URL will be generated.

![Webhook for Standup Bot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bl50vyb6aruploqld5gh.jpg)

## Scheduling Workflows

The workflow should be scheduled to run at the standup time. Suppose the standup time set by your organization is 10:00 AM PT every Mon-Fri. You can [create a scheduler](https://orkes.io/content/developer-guides/scheduling-workflows#creating-schedule) in the Conductor that ensures the workflow runs at the scheduled time.

A Scheduler can be created from your Conductor console by navigating to **Scheduler > Definitions** and providing the following CRON expression.

![Scheduler for Standup Bot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vo0ib0ywrio7ijho2kzk.jpg)

This ensures that the workflow runs at 10:00 AM PT every Mon-Fri. The UI also displays the local browser time. While creating the scheduler, ensure to choose the workflow name & the corresponding version to be scheduled.

Sample JSON for the scheduler is as follows:

```json
{
"name": "standup",
"cronExpression": "0 0 17 * * MON-FRI",
"startWorkflowRequest": {
   "name": "standup_updates_main",
   "version": "1",
   "input": {}
}
}
```

## Creating Slack App

Next, you must create a Slack App to integrate with your company’s Slack account. For this, navigate to https://api.slack.com/apps & click **Create an App**.

1. Provide an app name and pick your workspace where this app will be integrated.
2. Next, move to **Features > Incoming Webhooks** and turn on **Activate Incoming Webhooks**.
3. Then, move to **Features > Event Subscriptions**, and turn on **Enable Events**. Provide your Webhook URL under the field **Request URL**. Under **Subscribe to bot events**, click **Add Bot User Event** & add **_message.im_**.
4. Then, navigate to **Features > App Home**, and under the **Messages Tab**, enable the option _Allow users to send slash commands and messages from the messages tab_.
5. Finally, enable permissions for the Slack app by navigating to **Features > OAuth & Permissions**. Under **Scopes > Bot Token Scopes**, add **_chat:write_** permission.

 {% embed https://youtu.be/oIAqWhnA1pM %}

## Install App to Slack Workspace

Next, we must install this Slack app in your organization’s workspace.

1. From **Settings > Install App,** click **Install to Workspace**.
![Installing Slack App](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/335a7qh8tnsy20g5tz6l.jpg)
2. Choose the channel to where the app is to be installed.
![Choose the channel where Slack App is to be integrated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6vo66yjkjppdy24bwhhp.jpg)

Once the app is installed in your workspace, a **Bot User OAuth Token** will be generated. This is to be added as a secret in Conductor.

### Configuration Updates to be made 

If you want to try this in your Slack workspace, create the [secrets](https://orkes.io/content/developer-guides/secrets-in-conductor#creating-secrets) with your values in your Conductor console.

1. Navigate to **Secrets** from the left menu and create a new secret with a name; in this example, it is **slack_standup_token**, and the value is the OAuth token copied right now. The workflow definition specifies this secret value so that authorization will occur.
2. You also need to create another token; in this example, it is **slack_conductor_channel_url** with the Webhook URL copied from Slack.

Have a look at the following images for a better understanding of where you can get these values:

![Retrieving secret values](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4mbjopc48mximi0707p.jpg)

In the main workflow definition, for each of the sub-workflows added for the users, replace the **user_name** & **user_id** with your employee details:

```json
{
"name": "riza_updates",
"taskReferenceName": "riza_updates",
"inputParameters": {
"user_name": "Riza",
"user_id": "XXXXXXXXXX"// Go to Slack > View the profile > Click on three dots > Copy member ID
},
"type": "SUB_WORKFLOW",
```

## Workflow Execution

Let’s execute the workflow and see how it runs. In the actual example, the workflow would be automatically triggered during the standup time.

![Workflow Execution](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x444abo3p2lkqyvcsjp4.jpg)

So, the workflow is now waiting for the user’s update. Once the users open their Slack, they can see that the bot app has requested the update from the user.

![User providing the updates to the Bot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jsb7tzbl58seo6etejla.jpg)

Once the updates are posted, the user must send `done` towards the end. Instantly, the message would be posted on the standup channel.

![Updates posted by the bot in the channel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xfwhtuhka4bvcjxnau26.jpg)

On checking the workflow execution, you can see that the fork of this particular user is completed and is waiting for the updates from the other user. Once the second user posts the updates, the workflow gets completed.

![Workflow execution completed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isz4ogzx3jxbry44shky.jpg)

And we‘re done!

Here’s a video guide for the standup bot example:
{% embed https://youtu.be/lk6BxLM8upE %}

## Wrapping Up

We have successfully overcome one of our daily obstacles using powerful Conductor-Slack integration. Do you have similar challenges to be addressed? Orkes Conductor, built on the battle-tested Netflix Conductor, can help!

[Orkes Conductor](https://orkes.io/platform), the powerful orchestration platform, offers the cloud version of Netflix Conductor in all major cloud providers, including AWS, Azure & GCP.

If you require any assistance or have any inquiries, please don't hesitate to contact our team on [Community Slack](https://join.slack.com/t/orkes-conductor/shared_invite/zt-xyxqyseb-YZ3hwwAgHJH97bsrYRnSZg). We are always available to support you with your requirements.

Meanwhile, if you want to try Conductor for free, leverage [Orkes Playground](https://play.orkes.io/), a free developer sandbox.

If you find the experience valuable, we would greatly appreciate it if you could give us a 🌟 on our [Conductor](https://github.com/conductor-oss/conductor) repository!