<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: koooosuke</title>
    <description>The latest articles on DEV Community by koooosuke (@koooosuke).</description>
    <link>https://dev.to/koooosuke</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1061262%2Fb33563a0-4ef0-48f3-a5e0-26b4515e46ba.png</url>
      <title>DEV Community: koooosuke</title>
      <link>https://dev.to/koooosuke</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/koooosuke"/>
    <language>en</language>
    <item>
      <title>Automatically Generating TODO Lists from Slack Messages: Using llama_index and SlackLoader</title>
      <dc:creator>koooosuke</dc:creator>
      <pubDate>Mon, 29 May 2023 13:41:59 +0000</pubDate>
      <link>https://dev.to/koooosuke/automatically-generating-todo-lists-from-slack-messages-using-llamaindex-and-slackloader-1ng1</link>
      <guid>https://dev.to/koooosuke/automatically-generating-todo-lists-from-slack-messages-using-llamaindex-and-slackloader-1ng1</guid>
      <description>&lt;p&gt;In this tutorial, we'll demonstrate how to use llama_index and SlackLoader together to retrieve messages from Slack and automatically generate a TODO list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Python is installed&lt;/li&gt;
&lt;li&gt;Slack workspace is available&lt;/li&gt;
&lt;li&gt;Required Python packages are installed (dotenv, llama_index, etc.)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step-by-step Instructions:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Create a Slack App
&lt;/h3&gt;

&lt;p&gt;The first step is to create an app in your Slack workspace. This app will be used to fetch messages from a specific channel.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Visit the &lt;a href="https://api.slack.com/apps"&gt;Slack API&lt;/a&gt; site.&lt;/li&gt;
&lt;li&gt;Click on the &lt;code&gt;Create New App&lt;/code&gt; button.&lt;/li&gt;
&lt;li&gt;Choose &lt;code&gt;From scratch&lt;/code&gt;, give your app a name, select a workspace, and click the &lt;code&gt;Create App&lt;/code&gt; button.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Configure the Necessary Permissions
&lt;/h3&gt;

&lt;p&gt;You'll need to add the necessary permissions to your app.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to your app's settings page.&lt;/li&gt;
&lt;li&gt;From the left-side menu, select &lt;code&gt;OAuth &amp;amp; Permissions&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Under the &lt;code&gt;Scopes&lt;/code&gt; section, click on &lt;code&gt;Add an OAuth Scope&lt;/code&gt; button.&lt;/li&gt;
&lt;li&gt;Search for &lt;code&gt;channels:history&lt;/code&gt; and add it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 3: Install the App to Your Workspace
&lt;/h3&gt;

&lt;p&gt;Once you've set up the necessary permissions, you can install the app to your workspace.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click the &lt;code&gt;Install App to Workspace&lt;/code&gt; button at the top of the &lt;code&gt;OAuth &amp;amp; Permissions&lt;/code&gt; page.&lt;/li&gt;
&lt;li&gt;Review the required permissions and click &lt;code&gt;Allow&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 4: Post Test Data to Slack
&lt;/h3&gt;

&lt;p&gt;Post the following test data to any channel in your workspace. This message will be used to generate the TODO list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Today, I have several tasks on my plate: ... [continued]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Set Up Environment Variables
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;.env&lt;/code&gt; file and set up the following two environment variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SLACK_APP_TOKEN&lt;/code&gt;: The &lt;code&gt;Bot User OAuth Token&lt;/code&gt; for the app you installed in Step 3. You can get this from the &lt;code&gt;OAuth &amp;amp; Permissions&lt;/code&gt; page.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SLACK_CHANNEL_ID&lt;/code&gt;: The ID of the channel where you posted the test data in Step 4. This can be retrieved from the URL.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 6: Run Python Code
&lt;/h3&gt;

&lt;p&gt;Finally, run the following Python code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;dotenv&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;llama_index&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;GPTVectorStoreIndex&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;download_loader&lt;/span&gt;

&lt;span class="n"&gt;load_dotenv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;SlackReader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;download_loader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SlackReader"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SlackReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SLACK_APP_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;documents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;channel_ids&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SLACK_CHANNEL_ID"&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;

&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;GPTVectorStoreIndex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;from_documents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;documents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;query_engine&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as_query_engine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;query_prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"""
Based on what was posted in Slack today, could you please summarize your TODO list? Please structure your response in the following format:

- No: Task number
- Task: Brief description
- Status: (Not Started / In Progress / Completed)
- Due date: (if applicable)
- Any other relevant information or notes
"""&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query_engine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query_prompt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the above code, you should see an output similar to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Task: Conduct market research on competitors
   Status: Not Started
   Due Date: Friday

2. Task: Compile list of target media outlets
   Status: Not Started
   Due Date: Friday

3. Task: Prepare press release for new product
   Status: Not Started
   Due Date: Friday

4. Task: Meeting with design team to discuss packaging design
   Status: Not Started
   Due Date: Tomorrow (2 PM)

5. Task: Prepare for next sprint
   Status: Not Started
   Due Date: N/A

6. Task: Analyze customer feedback
   Status: Not Started
   Due Date: N/A

7. Task: Attend training for CRM system
   Status: Not Started
   Due Date: Monday

8. Task: Submit Q2 performance report
   Status: Not Started
   Due Date: End of Week

9. Task: Gather feedback on website design proposal
   Status: Not Started
   Due Date: Next Week

10. Task: Propose new project
    Status: Not Started
    Due Date: N/A

11. Task: Update budget report
    Status: Not Started
    Due Date: End of Month
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it! You should now be able to automatically generate a TODO list from messages posted in a specific Slack channel.&lt;/p&gt;

&lt;p&gt;Please note that llama_index and SlackReader are still under development and their functionality or usage might change in the future. So, it's always a good idea to keep an eye on the latest documentation or release notes.&lt;/p&gt;

</description>
      <category>python</category>
    </item>
  </channel>
</rss>
