Building Slack AI Assistants with Python & LangChain
ฝัง
- เผยแพร่เมื่อ 7 ก.ค. 2024
- 🚀 Kick-start your freelance career in data: www.datalumina.io/data-freela...
Here's a step-by-step guide to creating a Slack bot, installing it in a workspace, setting up Python code with LangChain and Flask, and using ngrok.
Interacting with AI agents via Slack provides a more natural way of communication and provides an integration with your team's workflow and allows for the integration of multiple bots for various tasks. This can improve efficiency and streamline communication, while also allowing the AI agents to become an integral part of your team.
🔗 Links
docs.datalumina.io/3y3XPD66nB...
github.com/daveebbelaar/langc...
⏱️ Timestamps
00:00 Introduction
00:44 What we will cover in this video
01:36 Why create a Slack bot?
04:05 Slack setup
07:07 Python setup
13:32 Server setup
17:23 Custom function setup
23:56 Why not just use ChatGPT?
25:54 What is Data Freelancer?
👋🏻 About Me
Hey there, my name is @daveebbelaar and I work as a freelance data scientist and coach. You've stumbled upon my TH-cam channel, where I give away all my secrets when it comes to working with data. I'm not here to sell you any data course - everything you need is right here on TH-cam. Making videos is my passion, and I've been doing it for 18 years. I just genuinely enjoy helping people.
While I don't sell any data courses, I do offer a coaching program for data professionals looking to start their own freelance business. If that sounds like you, head over to www.datalumina.io/ to learn more about working with me and kick-starting your freelance career. - วิทยาศาสตร์และเทคโนโลยี
You're a legend. I started learning Python just two months ago and I really didn't know anything about coding. Today, I can't believe what I'm able to do, so thanks a lot. My next goal will be to create an assistant who can write code for me. I need to practice LangChain and Prompt Engineering.
You are a rock star, Dave! Great tutorial. Have watched several of your videos on Langchain and I just finished building the slack bot thanks to your excellent instruction and overview. Thank you.
@DaveEbbelaar1... Yo Dave
wow... great... good to hear that you were able to successfully build the slack bot. I am stuck at Step 2 (load_dotenv(find_dotenv())) which is returning FALSE when run in interative mode. Are you able to assist?
haha nice new team member 😉, great guide, thank you, Dave. I know there are a lot of agents in LangChain supporting different documents, so it would be really exciting and helpful to handle them in one of the Slack channels.
Thanks Ivan! Definitely worth exploring for future videos 💭
This channel is criminally underrated
Great Job Dave !! keep it up!
Hats off! Very well explained!
Thank you Dave.
this got my sub! Thanks Dave!
thanks for sharing, it helps a lot, loving you!
your videos are great, really helping people man
This is so good. I love you Dave!
You're a rockstar dude 💪👏👏
Excellent video - With Langchain, you can surpass GPT limitations by incorporating tools and vector databases
Exactly!
Hey Dave when are you going to do part two of the video showing how to get Emma to do different tasks? A coding bot would be nice or further going into using a company’s db to feed back info when Emma is asked would also be great! Awesome video by the way thank you!
I second the connecting to the company's DB part, as long as no legal/security/privacy issue arises from this
Wow, that's a game changer
This is brilliant. It would be nice to see how to structure multiple bots in different channels. Should we bulit multiple bots in one app or one bot per app?
Thanks! Depends on what you want. Both would work.
Excellent Video Dave. I am stuck at Step 2, When I run (load_dotenv(find_dotenv())) this in interative mode in Visual Studio Code it is returning FALSE instead of TRUE. Any suggestions please
perfect
Great video. Thanks for the walkthrough. Why did you use 3.5 turbo instead of GPT-4?
I am on the waitlist for GPT-4
Emma's comments are absolute gold! 😆
She's a bit sassy 😂
@@daveebbelaar you should have hired a plain Jane instead 😉
Good one!, but suggest to not delegate delivering your videos by an AI, well,... not yet
they are all well explained and very clear,
Can I added it to group chat so she can analyze the chat then summarize it and if there’s tasks can it appoint the task to individual mentioned on the text 😅 I’m trying to do this but I’m not sure if it’s will work well
Really cool video, thanks! Do you think something like this for Discord would be more difficult to achieve?
Thanks! I think the process should be very similar for Discord.
@@daveebbelaar I tried doing somthing similar for discord some days ago before stumbling on your video, I was having issues getting to read the messages sent by the user. I came across an article that said something along the lines of discord changed their intents policy so as to keep messages more private and protected, except the bot is verified and permitted to do so, it will be hard to access users' message and feed the bot
Is personal data safe when you are linking the AI to your DB? D they own the rights to that data? Does anyone know how that works once the data is retrieved from your DB?
Great Project! But my slack is unable to verify the link. The terminal shows 403 Forbidden and slack shows the URL link did not respond to the challenge parameter. It would be great if someone could help me with the error.
thx for the great explanation!! Can u give me a suggest how can I get my bot user id easier, because following ur instructions is not completely for me clear how can I run my script I mean it give me back some errors but in the end everything works good
Same issue here, I use Pycharm to run the code
How would you connect the bot to Teams?
I see the OpenAI API is used but where do we put the key? ".env" file?
Yes in the .env file
Dave it's a great tutorial! Just working on setting up a slack agent, unfortunately I am stuck at 15:30 as the slack API doesn't verify the URL. I get the error message "Your URL didn't respond with the value of the 'challange' parameter". Any thoughts what the issue could be? I am running the ngrok server and see requests coming in when checking localhost:4040. Any help would be highly appreciated. THx
Did you sort this issue?
@daveebbelaar bump
@@pinaster0477 : th-cam.com/video/FDLZ4pcItko/w-d-xo.html
bump! same error here
Same here, it throws 401 Unauthorised in ngrok and flask, i tried regenerating signing secret but still same issue... this is a blocker ... @daveebbelaar quick response on this will be really helpful
Having issues with ngrok changing forwarding URL each session, leading to refreshes in slack api a must do, per session. Any work arounds to help keep this address static?
Unfortunately, that is not possible. It's kinda annoying but that is why this is a development setup.
Hello is there a way to contact you regarding one of these projects?
how to set up python interactive?
when i try to run the interactive terminal to get the bot toke id, i keep getting this error and don't know how to fix it.
ModuleNotFoundError: No module named 'slack_sdk'
however when i run pip list, it shows that it's there. slack-sdk 3.21.3
Make sure that you are installing in the correct environment and also using the correct environment in VS Code. You can also try to run `pip3 install slack_sdk`
A free hosting server would be great
for the env your doc is missing the ai part. here is the code - OPENAI_API_KEY= "insertkeyhere"
Thanks! I've updated it ;)
Hi. Thanks for your videos… just a curiosity (off topic) where are you from? I’m curious about your “v’s”: for my ears sound like “f’s” which is common in my natural Valencia (Spain) and in Brazilian Portuguese… so… you seem to be north European so which is your most used language? Cheers!
Haha you are not the first one to mention that. I wasn't even aware of it. I am from the Netherlands ;)
@@daveebbelaar Really interesting how different languages have things in common… thanks for answering!
comment for the algorithm :)
Thanks! 😁
Can we use it on whatsapp business?
@dave does this require a paid ngrok account to work?
Nope, I used the free version.
nice ! thank you :D I will sub your channel. I hope you can teach or show how I can connect it to a database , so it can read our company data
!
Can Emma be animated and use a resident text to speech app?
If only Emma could wash the dishes and clean the bathroom.
5 years haha
coming soon
Lol
Can we make a chatbot like this for WhatsApp ?
I called mine Craig
Hey Dave, really good content, can't get enough :)
Maybe someone can help with this error: urllib.error.URLError:
What to do now?
Im getting the same error
Me too
@@nicolascort
Add this under the import os on line 1
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
@@dawsongrattidge1695 Add this under the import os on line 1
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
@@jamesmccombe7289 worked as a charm! Thanks!
YO ANYBODY NOTICE PYTHON IS SPELLED AS PYTON IN THE DOC!
BRO CORRECT IT
sorry bro
1. Extremely complicated solution for something really simple. But yes, i understand that more things can be done.
2.Implementing prompt templates in a vsto addon for outlook would be much more convenient.
3.If your email is in browser gramerlyGo already writes your email.
4. No talk about data privacy. Is it really ok to send the email you received to OpenAI? The sender did not agree to this. You might have NDA in place...
5. Making a local LLM write email would be quite slow.
6. No mention of the fact that copy paste into chatGPT is free, while using the API is expensive.
Man, email is not alone in big IT forest.
nice video, but would have been nice to know it is not beginner friendly, and some sort of python knowledge, would not have wasted time. thanks anyway.
LOL, are your replies to youtube comments generated by an AI assistant too?
Haha nope, that is still the real me - for now 👀
Stupid human with his incompetent brain was not even able to spell his own name correctly in Slack...
Having a hard time getting the bot_user_id using your method at 9:50 , can't seem to run the code in the interactive window as you did in the video , When I try to run the code:
"import os
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
from slack_bolt.adapter.flask import SlackRequestHandler
from slack_bolt import App
from dotenv import find_dotenv, load_dotenv
from flask import Flask, request
from functions import draft_email
# Load environment variables from .env file
load_dotenv(find_dotenv())"
I KEEP GETTING THIS ERROR
: "False
Output exceeds the size limit. Open the full output data in a text editor---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
c:\Users\15199\Desktop\AIExperiments\langchain-experiments\slack\app.py in line 8
6 from dotenv import find_dotenv, load_dotenv
7 from flask import Flask, request
----> 8 from functions import draft_email
9 # Load environment variables from .env file
11 load_dotenv(find_dotenv())
File c:\Users\15199\Desktop\AIExperiments\langchain-experiments\slack\functions.py:1
----> 1 from langchain.chat_models import ChatOpenAI
2 from langchain.chains import LLMChain
3 from dotenv import find_dotenv, load_dotenv
File c:\Users\15199\AppData\Local\Programs\Python\Python310\lib\site-packages\langchain\__init__.py:6
3 from importlib import metadata
4 from typing import Optional
----> 6 from langchain.agents import MRKLChain, ReActChain, SelfAskWithSearchChain
7 from langchain.cache import BaseCache
8 from langchain.callbacks import (
9 set_default_callback_manager,
10 set_handler,
11 set_tracing_callback_manager,
12 )
...
---> 26 def get(self, url: str, **kwargs: Any) -> requests.Response:
27 """GET the URL and return the text."""
28 return requests.get(url, headers=self.headers, **kwargs)
AttributeError: partially initialized module 'requests' has no attribute 'Response' (most likely due to a circular import)"
and I cant seem to find a solution to get past that. Please suggest what I can do, I am new to learning Data science and Machine Learning using the jupyter interactive window, Please suggest what should I do to get past this step or any resources you can recommend to get more knowledge on this top. Appreciate your content a lot, Thank you!
having difficulties obtaining my SLACK_BOT_USER_ID