DEV Community

Cover image for Asynchronous Daily Thread Automation
Sibelius Seraphini for Woovi

Posted on • Updated on

Asynchronous Daily Thread Automation

Daily Thread

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

Automation Step by Step

We set up the slack bot using @slack/bolt

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

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

slackApp.message(/Daily thread/, dailyThreadCommand);
Enter fullscreen mode Exit fullscreen mode

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.

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);
}
Enter fullscreen mode Exit fullscreen mode

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 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!


Photo by Lenny Kuhne on Unsplash

Top comments (0)