Summarize a Slack thread with AI
Long Slack threads are where decisions get made and then lost. This guide builds a workflow that summarizes a thread on request: anyone reacts to a message in the thread with 📝, and an AI Prompt step reads the whole thread and replies in it with the decisions, the open questions, and who agreed to do what. The owner of each action item is mentioned, so they get a notification.
The finished workflow has these steps:
Before you start
Section titled “Before you start”- You need the Developer role in a KloudMate workspace whose plan includes workflows.
- You need a Slack connection with the Workflows capability. The workflow works in every channel the KloudMate bot is in, so invite the bot to the channels where you want summaries.
- Each summary uses workflow credits, and the AI Prompt step uses more. See Check workflow usage.
Step 1: Import the workflow
Section titled “Step 1: Import the workflow”- Copy the YAML below.
- Open Workflows, click Import, paste the YAML, and click Import.
- Click Open workflow. On the trigger, pick your Slack connection under Account, and on the two Slack steps, pick your Slack connection.
How each step works
Section titled “How each step works”The trigger
Section titled “The trigger”The Slack Reaction added trigger has Only this emoji set to memo, Slack’s name for 📝, so any other reaction is ignored. Only in channel is empty, so a 📝 in any channel the bot is in starts a run. The event carries the reacted message’s channel and timestamp as trigger.event.item.channel and trigger.event.item.ts, and the person who reacted as trigger.event.user.
Read the thread
Section titled “Read the thread”A Slack Get Thread Replies step reads the thread, with Channel and Thread set from the event. Thread can be the timestamp of any message in the thread, so a 📝 on a reply works as well as one on the first message. Max messages is 200.
Slack returns the thread in messages, oldest first, with the message that started the thread at position 0.
A Branch checks that steps.thread.output.messages.1 is not empty, which means the thread has at least one reply. A 📝 on a message with no replies does nothing.
Summarize the thread
Section titled “Summarize the thread”An AI Prompt step writes the summary. The Prompt sets the sections and the length, and then lists the thread with a Liquid for loop, one message after another:
Each message starts with its author’s user ID in Slack’s mention syntax, <@U02ABCDEF>. The prompt asks the model to name the owner of each action item the same way, so the owners are mentioned when the summary is posted, and Slack shows their names.
The prompt also tells the model not to add anything the thread doesn’t say. A summary that invents a decision is worse than no summary, so check a few summaries against their threads when you start.
AI Prompt reads the messages as part of its instructions, so whoever writes in the thread can steer the summary. That’s acceptable here, because the people in the thread are your colleagues, and the summary only goes back into the same thread. For text from outside your company, use AI Extract instead. See AI Prompt.
Reply with the summary
Section titled “Reply with the summary”A Slack Post Message step replies in the thread, with Reply to thread set to {{ steps.thread.output.messages.0.ts }}, the first message of the thread. The reply names who asked for the summary:
The replace filter turns <! into <!. That keeps the summary from notifying a whole channel with <!channel> or <!here>, even if a message in the thread tricked the model into writing one. User mentions, which start with <@, still work.
Step 2: Test and publish
Section titled “Step 2: Test and publish”- Open the trigger’s Test tab and click Test trigger. Then react with 📝 to a message in a thread in a channel the bot is in. The reaction becomes the trigger’s sample.
- Test Read the thread from its Test tab, then test Summarize the thread to see the summary without posting it.
- Click Publish. The first publish also switches the workflow on.
Adapt the workflow
Section titled “Adapt the workflow”- Save the summary in Jira. For threads about a Jira issue, add an AI Extract step that returns the issue key mentioned in the thread, and a Jira Add Comment step that posts the summary on that issue.
- Summarize only some channels. Import the workflow once for each channel, each with a different
uid, and set Only in channel on each trigger. - Write a different summary. Change the sections in the prompt, for example to a timeline for an incident thread, or to a list of open questions only.
Related
Section titled “Related”- AI Prompt and AI Extract for when to use each one.
- Templating for
forloops in a template. - Triggers for Slack events.