by Lazy Sloth
Slack Thread Summarizer App
import os
from slack_bolt import App
from slack_bolt.adapter.socket_mode import SocketModeHandler
from abilities import llm_prompt
import re
# Initialize the Bolt app with the token and signing secret
app = App(token=os.getenv('SLACK_BOT_TOKEN'))
def summarize_text(text):
# Clean the text by removing emojis and images
clean_text = re.sub(r':[^:]+:', '', text) # Removes Slack emojis
clean_text = re.sub(r'<[^>]+>', '', clean_text) # Removes image URLs or any Slack-specific markup
# Use the llm_prompt ability to generate the summary
prompt = (
"Please summarize the following text into key takeaways in English. "
"The response should be in bullet points, each one concise and to the point. "
"Minimize the number of bullet points and avoid repeated content. "
"Ignore any emojis and images. If there is text in any other language, "
"provide a summary of that text in English. Here is the text:\n\n" + clean_text
)
summary = llm_prompt(prompt)
return summary
Frequently Asked Questions
How can the Slack Thread Summarizer App benefit my team's communication?
The Slack Thread Summarizer App can significantly improve your team's communication by providing concise summaries of lengthy Slack threads. This saves time for team members who need to quickly catch up on discussions without reading through entire conversations. It's particularly useful for managers overseeing multiple projects or for team members returning from time off. By distilling key points into bullet-point summaries, the app ensures that important information is not overlooked, enhancing overall team productivity and information retention.
Can the Slack Thread Summarizer App handle multilingual conversations?
Yes, the Slack Thread Summarizer App is designed to handle multilingual conversations. If there is text in any language other than English in the thread, the app will provide a summary of that text in English. This feature makes the app particularly valuable for international teams or companies with global operations, as it helps bridge language barriers and ensures that all team members can understand the key points of any conversation, regardless of the original language used.
How does the Slack Thread Summarizer App ensure data privacy and security?
The Slack Thread Summarizer App prioritizes data privacy and security in several ways. First, it only processes messages within threads where it's explicitly mentioned, ensuring that it doesn't access conversations unnecessarily. Second, it filters out messages sent by bots and messages where the bot itself is mentioned, focusing only on relevant human communication. Additionally, the app uses environment variables for sensitive information like API tokens, which is a security best practice. However, it's important to note that the summarization process involves sending data to an external LLM service, so organizations should review the privacy policies of the LLM provider being used.
How can I modify the Slack Thread Summarizer App to use a different LLM provider?
To use a different LLM provider with the Slack Thread Summarizer App, you'll need to modify the llm_prompt
function in the abilities.py
file (which is imported but not shown in the provided code). Here's an example of how you might modify this function to use OpenAI's GPT-3:
```python import openai
def llm_prompt(prompt): openai.api_key = os.getenv("OPENAI_API_KEY") response = openai.Completion.create( engine="text-davinci-002", prompt=prompt, max_tokens=150 ) return response.choices[0].text.strip() ```
Remember to install the necessary package (pip install openai
) and set the OPENAI_API_KEY
environment variable with your API key.
Can I customize the summarization prompt in the Slack Thread Summarizer App?
Absolutely! The summarization prompt can be easily customized in the summarize_text
function. Here's an example of how you might modify the prompt to focus on action items instead of general summary:
```python def summarize_text(text): clean_text = re.sub(r':[^:]+:', '', text) clean_text = re.sub(r'<[^>]+>', '', clean_text)
prompt = (
"Please extract the main action items from the following text. "
"The response should be in bullet points, each one starting with an action verb. "
"Focus only on concrete tasks or decisions made. "
"If there are no clear action items, state that. Here is the text:\n\n" + clean_text
)
summary = llm_prompt(prompt)
return summary
```
This modification would change the Slack Thread Summarizer App to focus on extracting action items from conversations, which could be particularly useful for project management or task-oriented teams.
Created: | Last Updated:
Introduction to the Slack Thread Summarizer App Template
Welcome to the Slack Thread Summarizer App template! This template is designed to help you create an application that listens for mentions in a Slack thread and provides a concise summary of the conversation. It's perfect for keeping up with important discussions without having to read through every message. Let's walk through the steps to get your app up and running on the Lazy platform.
Clicking Start with this Template
To begin using this template, simply click on the "Start with this Template" button in the Lazy Builder interface. This will pre-populate the code in the Lazy Builder, so you won't need to copy, paste, or delete any code manually.
Initial Setup: Adding Environment Secrets
Before testing your app, you'll need to set up some environment secrets. These are not the same as environment variables in your operating system; they are specific to the Lazy platform and can be set in the Environment Secrets tab within the Lazy Builder.
You will need to provide the following environment secrets:
- SLACK_BOT_TOKEN: The token for your Slack bot. You can obtain this from your Slack app's settings under the OAuth \& Permissions section.
- SLACK_APP_TOKEN: The token for your Slack app to use socket mode. This can be generated in your Slack app's settings under the Socket Mode section.
Make sure to keep these tokens secure and do not share them publicly.
Test: Pressing the Test Button
Once you have set up the necessary environment secrets, you can test your app by pressing the "Test" button in the Lazy Builder. This will deploy your app and launch the Lazy CLI. There is no need for user input at this stage, as the app will operate based on events within Slack.
Using the App
After deploying your app, it will listen for mentions in Slack threads. When your bot is mentioned, it will fetch the thread's messages, filter out those from bots or containing mentions of the bot, and then summarize the conversation. The summary will be posted back into the same thread.
Integrating the App
To integrate this app with your Slack workspace, you need to have a Slack bot set up with the appropriate permissions. Ensure your bot has permissions to read messages and post in threads where it is mentioned. You may need to invite the bot to the channels where you want it to operate.
If you need to reference the Slack API documentation for further details on permissions and bot setup, you can find it at Slack API Documentation.
That's it! You now have a Slack Thread Summarizer App ready to help you stay on top of important conversations in your Slack workspace. Enjoy the convenience of automated summaries and never miss out on key takeaways from your team's discussions.
Template Benefits
-
Improved Communication Efficiency: This Slack app can significantly reduce time spent reading long threads by providing concise summaries, allowing team members to quickly grasp key points without sifting through entire conversations.
-
Enhanced Decision Making: By distilling complex discussions into bullet-point summaries, the app facilitates faster and more informed decision-making processes, especially useful for managers and executives who need to stay updated on multiple team discussions.
-
Multilingual Support: The app's ability to summarize text in any language and provide an English summary breaks down language barriers in international teams, promoting better collaboration and understanding across diverse workforces.
-
Increased Productivity: By automating the task of summarizing conversations, employees can focus on more value-added activities, leading to improved overall productivity and reduced cognitive load from information overload.
-
Knowledge Management: The app serves as a tool for capturing and preserving key insights from discussions, making it easier to reference important information later and contributing to the organization's knowledge base.