Asynchronous Daily Thread Automation
Tags: async, daily, thread, automation
Published: 2023-03-20 13:01:11


![Daily Thread](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2v5mlkz2zy98ojrv5w2t.png)

## What is an asynchronous Daily Thread?

At Woovi, we have a Daily meeting so everyone can provide a gist of what they are working on, if they are blocked or not, if they need help.

We also have the same idea in Woovi Slack by text. We set up a reminder that creates a message on #general channel with the name `Daily thread` that everyone needs to reply.

The problem is that people forget about it, so we decided to automate tagging people who already replied to the thread.

Below is the `Botina`, Woovi slack bot, tagging people that didn't replied the Daily thread until now.

![Reminder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ly197gnjde2evvtebqhj.png)

## Automation Step by Step

We set up the slack bot using `@slack/bolt` 

```jsx
export const slackApp = new App({
  token: config.TOKEN,
  appToken: config.APP_TOKEN,
  signingSecret: config.SIGNING_SECRET_TOKEN,
  socketMode: true,
  port: config.PORT || 3000,
});
```

We set up a message command that listen to `Daily thread` message:

```jsx
slackApp.message(/Daily thread/, dailyThreadCommand);
```

This is the command to tag people that haven't answered the thread yet.

Here is the logic of it. 
It awaits for 30 minutes to tag people. 
It reads replies messages to `Daily Thread` message. 
It finds users that should but not replied yet. 
It sends a message tagging them.

```jsx
export const dailyThreadCommand = async ({ message, say }) => {
  // wait 30 minutes
  setTimeout(async () => {
    const dailyThreadMessage = message;

    const replies = await slackApp.client.conversations.replies({
      channel: generalChannelId,
      ts: dailyThreadMessage.ts,
    });

    const usersReplied = unique(filterBots(replies.messages.map(m => m.user)));

    if (usersReplied.length === allMembers.length) {
      // eslint-disable-next-line
      console.log('all members replied');
      return;
    }

    const messageToSend = removeRepliedUsers(replaceMembers(allMembers.join(' ')), usersReplied).trim()

    if (!messageToSend) {
      // eslint-disable-next-line
      console.log('all members replied');
      return;
    }

    await slackApp.client.chat.postMessage({
      token: config.TOKEN,
      channel: generalChannelId,
      text: messageToSend,
      thread_ts: dailyThreadMessage.ts,
    });
  }, EVERY_30_MINUTE);
}
```

## In Summary
If you are creative enough, you can automate more and more of your workflows.

What kind of automations are you working on?


---
Woovi
[Woovi](https://www.woovi.com) is a Startup that enables shoppers to pay as they like. To make this possible, Woovi provides instant payment solutions for merchants to accept orders.

If you want to work with us, we are [hiring](https://woovi.com/jobs/)!

---
Photo by <a href="https://unsplash.com/@lennykuhne?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Lenny Kuhne</a> on <a href="https://unsplash.com/photos/jHZ70nRk7Ns?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>