Тёмный

Python Slack Bot Tutorial #2 - Handling Events (Events API) 

Tech With Tim
Подписаться 1,6 млн
Просмотров 83 тыс.
50% 1

In this python slack bot tutorial we will learn how to handle events from our slack bot using the slack events api. The slack events api will allow for us to subscribe to events and be informed when slack events occur. We will use flask to retrieve and handle these events.
💻 Ngrok Download: ngrok.com/
📖 Full Series Code: github.com/tec...
📕 Slack API Website: api.slack.com/
📗 Slack Website: slack.com/intl...
📚 Playlist: • Python Slack Bot
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
🔊 Subscribe to my second channel for weekly podcasts! / @timeoutwithtim
💰 Courses & Merch 💰
💻 The Fundamentals of Programming w/ Python: tech-with-tim....
👕 Merchandise: teespring.com/...
🔗 Social Medias 🔗
📸 Instagram: / tech_with_tim
📱 Twitter: / techwithtimm
⭐ Discord: / discord
📝 LinkedIn: / tim-ruscica-82631b179
🌎 Website: techwithtim.net
📂 GitHub: github.com/tec...
🔊 Podcast: anchor.fm/tech...
🎬 My RU-vid Gear 🎬
🎥 Main Camera (EOS Canon 90D): amzn.to/3cY23y9
🎥 Secondary Camera (Panasonic Lumix G7): amzn.to/3fl2iEV
📹 Main Lens (EFS 24mm f/2.8): amzn.to/2Yuol5r
🕹 Tripod: amzn.to/3hpSprv
🎤 Main Microphone (Rode VideoMic Pro): amzn.to/3d0KKMG
🎤 Secondary Microphone (Synco Wireless Lapel System): amzn.to/3e07Swl
🎤 Third Microphone (Blue Yeti USB Mic): amzn.to/3hoD625
☀️ Lights: amzn.to/2ApeiXr
⌨ Keyboard (Daskeyboard 4Q): amzn.to/2YpN5vm
🖱 Mouse (Steelseries Rival 300): amzn.to/3cVTqnD
📸 Webcam (Logitech 1080p Pro): amzn.to/2B2IXcQ
📢 Speaker (Beats Pill): amzn.to/2XYc5ef
🎧 Headphones (Bose Quiet Comfort 35): amzn.to/2MWbl3e
🌞 Lamp (BenQ E-reading Lamp): amzn.to/3e0UCr8
🌞 Secondary Lamp (BenQ Screenbar Plus): amzn.to/30Dtafi
💻 Main Monitor (LG 4K): amzn.to/37ybtiH
💻 Secondary Monitor (Thinkvision 1080p): amzn.to/2AyHR8H
🎤 XLR Microphone (Rode NT1): Not available
🎙 Mic Boom Arm (Rode PSA 1): amzn.to/30EZw9m
🎚 Audio Interface (Behringer 4 Channel): amzn.to/3fqm4z3
💾 Recorder (Zoom H6): amzn.to/2UIihVJ
◾ 💸 Donations 💸 ◾
💵 One-Time Donations: www.paypal.com...
💰 Patreon: / techwithtim
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
⚡ Please leave a LIKE and SUBSCRIBE for more content! ⚡
⭐ Tags ⭐
Tech With Tim
Slack Bot Tutorial
Slack Events API
Slack Bot Handled Events
Python Slack Events
Slack Events Python
Slack Bot Events API
⭐ Hashtags ⭐
#Python #Slack

Опубликовано:

 

5 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 123   
@reuvenbrooks7943
@reuvenbrooks7943 2 года назад
Hi Tim! Thanks for the tutorial! Its super clean! Id like to share one thing. This method not works on Private Channel. Here is the extra: 1. *Event Subscriptions* > *Subscribe to bot events* > *Add Bot User Event* > add *message.groups* 2. Required Scope is *groups:history* but it will be autoadd in *Bot Token Scopes* 3. *Reinstall to Workspace* And it works well
@junicnt
@junicnt 2 года назад
Nice tips! tks.
@PavelRipper
@PavelRipper Год назад
I am grateful to you! Thanks for your tip
@sha16
@sha16 Год назад
You help me a lot! Thanks!
@nickex9369
@nickex9369 Год назад
Top man!
@ritvikkarra1916
@ritvikkarra1916 Год назад
Thank you! This was super helpful
@unknownuseracc1949
@unknownuseracc1949 4 года назад
I apologize for the possible rudeness, but! I do not understand damn how such a nice young man can explain so beautifully, clearly. having the skills of adult teachers (explaining slowly and with patience) is a talent ... just bravo, and thank you very much for your work, bro.
@TechWithTim
@TechWithTim 4 года назад
Hey no rudeness there haha. Thanks!
@unknownuseracc1949
@unknownuseracc1949 4 года назад
@@TechWithTim just wanted to share my opinion with you, dude. Good luck! You'll get ur success 💪
@kassandrarodriguez8057
@kassandrarodriguez8057 2 года назад
for anyone that was getting 403 Forbidden in ngrok response. i change the port on flask to 5002 and same for ngrok and it started working for me
@Sha08ker
@Sha08ker Год назад
Thanks
@lukasmohr94
@lukasmohr94 Год назад
How can i change the port on flask?
@aaditya_jagdale
@aaditya_jagdale 4 месяца назад
Straight to the point and super useful playlist
@wickywills
@wickywills 3 года назад
I’ve only just started getting into Python and this is great!
@lewisrobson9414
@lewisrobson9414 3 года назад
for anyone that has had the problem Your URL didn't respond with the value of the challenge parameter. make sure you have no local firewall blocking connections out or in
@elements8630
@elements8630 2 года назад
still facing the same issue. any help?
@shreyashervatte5495
@shreyashervatte5495 2 года назад
Hey Tim, just wanted to let you know your Slack Token is exposed at 7:40. Thanks for the video!
@alexdolea7778
@alexdolea7778 2 года назад
Issue with "challenge" when submitting the URL from ngrok I've tried to find a solution but nothing. But after disabling AirPlay Receiver in System Preferences > Sharing and then restarting the laptop, it eventually worked. I am on a Macbook M1 MAX Monterey 12.4
@ianschneider6232
@ianschneider6232 2 года назад
Hey Alex, many thanks for the tips. Saved my day =)
@faneeshmunjal2880
@faneeshmunjal2880 4 года назад
6th yes! this shows I am a loyal viewer in regards to TWT i.e tim
@plusk343
@plusk343 4 года назад
Are you too addicted to among us? Lol justifying yourself 😂😂 jk
@kaminey26
@kaminey26 2 года назад
Clean, crisp, engaging. A1 quality content. Keep rocking it!
@santoshverma33
@santoshverma33 Год назад
Thank you. Great Tutorial! Just wanted to know, How can we send direct message to a user?
@JoseLuna-ib3ch
@JoseLuna-ib3ch 2 года назад
Your content is really good man, very very good explanations. Congrats!
@BenjaminDenverstone
@BenjaminDenverstone 4 года назад
Can't wait to get into Python. I have to wait until June 2021. I still have to learn more JavaScript, DOM, React, REST, Cypress.io, etc. I'm starting with Scope and Closures in JavaScript Monday.
@Mushbeary
@Mushbeary 4 года назад
Why are you learning all these other languages before you go into python?
@Helpmecry
@Helpmecry 4 года назад
@@Mushbeary yes i recommend python as the first programming language
@dillonbarnes232
@dillonbarnes232 3 года назад
You showed the SLACK_TOKEN at 7:36
@shahul111
@shahul111 3 года назад
Hi Tim. Challenge parameter returned is failing with below response and body has challenge parameter.. Please help "code" : 200, "error" : "challenge_failed" , "body" : { "xxxxxxxyyyyyyyxxxxxzzzz" }
@alexsouzabh
@alexsouzabh 2 года назад
Are you running on a Mac? I dont know, but i need to change the port on Python and on ngrok. I used 8000
@Santore.
@Santore. 2 года назад
Very helpful and step by step explanation
@TechWithRushabh
@TechWithRushabh 4 года назад
Hey Tim, Great Tutorial. I wanted to know how you actually figured things out? like how u know ngrok how you know about the payload. Documentation ?
@sanjayrajasreeraja3456
@sanjayrajasreeraja3456 4 года назад
@Techwithtim can u make a video explaining the rules and how to submit our project for the tim jam
@kevinkennethp995
@kevinkennethp995 2 года назад
i have no error . when i send message in channel .bot is not replying me back. can any one help me in this.. thanks in advance
@SiddharthSinghFiery69
@SiddharthSinghFiery69 Год назад
Same issue.
@slavalenskyy6145
@slavalenskyy6145 2 года назад
Thank you. This tutorial helped me a lot.
@macx4044
@macx4044 3 года назад
Great tutorial! but I have a question, how can default retries be handled? The bot executes a function that takes a few minutes to finish, for that reason slack executes the retries.
@chinmaykulkarni3078
@chinmaykulkarni3078 3 года назад
I was trying to find - how can we handle callbacks? Thanks to you! Your video and ngrok helps me a lot. cheers!
@rishaditya
@rishaditya 3 года назад
Thanks a lot for the super clear explanation!
@stiljohny
@stiljohny 3 года назад
May I suggest you try running the tutorials in Venv that way new users of python get o see how it will be installing a bunch of modules etc
@herbertgutierrez6729
@herbertgutierrez6729 2 года назад
Amazing bro. Your're doing amazing
@bimalpatel5859
@bimalpatel5859 2 года назад
How can i Know the user_auth_Token it ask for code How to generate
@debjyotichattopadhyay6679
@debjyotichattopadhyay6679 3 года назад
Why do you need to use the slack_event_adapter for setting the route , when you are already setting the route in the event subscription page in slack docs
@andrewli5888
@andrewli5888 4 года назад
First! Can't wait to watch this video!
@otteydw
@otteydw 3 года назад
I'd recommend using the https URL so that the connection is encrypted.
@tonywang535
@tonywang535 3 года назад
Thank you for the clear tutorial. It really clears some of the confusing part of Slack API! I have question, how to make message.app_home listener? I tried the same approach you listed here but it does not work.
@mz_finessed4185
@mz_finessed4185 4 года назад
Hey Tim can you do more javascript or html pls
@SiddharthSinghFiery69
@SiddharthSinghFiery69 Год назад
I'm able to post a message on a Slack channel using the script that's shown in this video but not able to trigger the events handling, meaning when I type a message on my channel, I do not get any response from the Slackbot. Has anyone faced a similar issue ? If so, how did you resolve it ?
@KundanKumar-uj2in
@KundanKumar-uj2in Год назад
I have faced the same issue how to handle it? Do you know?
@lakshmikumari9970
@lakshmikumari9970 Год назад
Hey I got the same issue even though there is no error, did you resolved it?
@SiddharthSinghFiery69
@SiddharthSinghFiery69 7 месяцев назад
​@@lakshmikumari9970Hey yeah I resolved it. Make sure your text isn't NoneType and event is not null. Right now, I'm trying to use socket mode to cut down events subscription and the requirement of a request URL.
@doggo3485
@doggo3485 3 года назад
Hey Tim, I noticed that somewhere near 8:30 when I run the code I get a *KeyError: 'SIGNING_SECRET'*, do you know a fix for this?
@doroke
@doroke 3 года назад
You need to do the load_dotenv call before instantiating the SlackEventAdapter
@TheSimpleUrbanLife
@TheSimpleUrbanLife 3 года назад
@@doroke I see that in the video he has already instantiated the load_dotenv. Do you want us to do it twice?
@programmingnothing
@programmingnothing 3 года назад
Awesome your tutorial...
@ashokmamnani6380
@ashokmamnani6380 3 года назад
Bot still sending message repeatedly what to do ?
@parthsharma197
@parthsharma197 4 года назад
Hey Tim , can u please tell how to use python script in website or convert python script to javascript to use it in a website. Btw great video bro🙂🙂 And are all python modules like matplot can be used in javascript
@abrahamlora3650
@abrahamlora3650 2 года назад
Hey Thanks for the helpful information regarding this. What if I am looking to obtain messages from an specific channel and move it to another channel?
@SergioGonzálezRetamero
@SergioGonzálezRetamero Год назад
After the last part, configuring the "def message(payload)", the bot doesn't react anymore, neither Ngrok is registering any petitions. Any help?
@eugenenagirny563
@eugenenagirny563 3 года назад
Hi, can someone advice, I've created bot using this tutorial, but now I need it to be deployed somewhere, is it possible deploy it somehow in my workspace?
@tysonchen9466
@tysonchen9466 Год назад
I would also like to know how to do this
@KundanKumar-uj2in
@KundanKumar-uj2in Год назад
I tried hard to look at everything I could miss but it is not working.
@Tommy-jn9ps
@Tommy-jn9ps 3 года назад
i just wanna ask. On the machine learning tutorial you were using pycharm and you set up the tenserflow package i believe nad all the others. How can you do that in python? i remember you went to file and then settings but in vs code theres no such as settings in file. I will appriciate any sort of help.
@ritviks8827
@ritviks8827 Год назад
For the ngrok step, when adding the url to slack, I keep getting an error: "Your URL didn't respond with the value of the challenge parameter." I used the /slack/events format. Any ideas what went wrong?
@rogerchen3663
@rogerchen3663 Год назад
Did you end up figuring it out?
@ritviks8827
@ritviks8827 Год назад
@@rogerchen3663 Sadly, I did not find out what was causing the error, but I did find out that ngrok is working fine and the issue seems to be with the python code. Not sure exactly what the issue with the python code is as I triple checked to ensure every character is the same as in the video.
@ritviks8827
@ritviks8827 Год назад
Hey, just wanted to let you know that it works now. I just changed my development device from my m1 mac to my windows device. This seemed to do the trick. Not sure what went wrong originally as I copied and pasted the same code from my m1 mac onto my windows device and it worked with no errors.
@saurabhshinde6886
@saurabhshinde6886 Год назад
@@ritviks8827 port 5000 on Mac is used by Airplay receiver, thats why you were seeing the 403 error and challenge was failing, you can just change the port to something other than 5000 and it will work on Mac too.
@hudsonr
@hudsonr 8 месяцев назад
@@saurabhshinde6886 OH MY GOSH THANK YOU SO MUCH. LIFE SAVER
@TechWithRushabh
@TechWithRushabh 4 года назад
Make a tutorial on impleting AI on this bot
@helluci6449
@helluci6449 4 года назад
4 mins uploaded 20 mins video already has 8 likes 1 dislike. Why?How? Did he just summon the Patreons? :D
@alexandrnita8855
@alexandrnita8855 8 месяцев назад
How to send a message directly to a user? Thanks
@venkatesh2788
@venkatesh2788 4 года назад
Bro make a video about artificial intelligence and what we will study in it
@itzzDizZY
@itzzDizZY 2 года назад
Might be too late to ask the question but the Ngrok step isn't working for me. It keeps giving 403 Forbidden error, can't seem to get it work. Anyone knows why would this happen?
@sivaldosilva1958
@sivaldosilva1958 Год назад
2 years laters and i no ones cant figure out how to solve the error KeyError: 'SIGNING_SECRET' ? pleaseee
@Laurynhere
@Laurynhere Год назад
do I *need* to use the webserver? I am practicing on my work PC and I can't install ngrok lol
@rachit6099
@rachit6099 4 года назад
ello tim great video edit: just removed :peep: cuz it didn't worked
@thelordsofgaming2153
@thelordsofgaming2153 4 года назад
when your gonna do the webssite thing with javascript, jquery, python and django or flask, idk i dont really remember?
@praneethvasarla8825
@praneethvasarla8825 3 года назад
My slack events adapter is not getting triggered upon receiving a message. I'm able to post a message to the channel but I'm not able to receive the messages. can someone help me, please?
@JoHaNnA910923
@JoHaNnA910923 3 года назад
i have the same issue, could u fixe it?
@praneethvasarla8825
@praneethvasarla8825 3 года назад
@@JoHaNnA910923 After days of debugging, it turned out that for some reason the app itself was corrupted. Simply creating a new app and changing the tokens in the code resolved my issue. Try this once and let me know if it helped
@karamanabdullah
@karamanabdullah 3 года назад
@@praneethvasarla8825 what is real solution?
@SiddharthSinghFiery69
@SiddharthSinghFiery69 Год назад
@@praneethvasarla8825 I have the same issue. Able to post a message on a Slack channel using the script that's shown in this video but not able to trigger the events handling, meaning when I type a message on my channel, I do not get any response from the Slackbot. What tokens did you change in the code ? The Bot token and the Signing Secret right ?
@AlejotheFATkid
@AlejotheFATkid 4 месяца назад
Stuck on the HTTP thing with ngrok getting a 502 Bad gateway any one know what setting i need to change in windows 11 to get this to work ?
@brianharrington9289
@brianharrington9289 2 года назад
What script would I run to setup all replies to automatically go to a thread?
@LesterFD
@LesterFD 2 года назад
Thank you
@MindqueBlast
@MindqueBlast 3 года назад
Can anybody tell me why my ngrok says 500 Internal server error and when i put in the request it says "Your URL didn't respond with the value of the challenge parameter." I fllowed all the steps and I don't know why i keep getting these errors
@netishmb761
@netishmb761 8 месяцев назад
4:05 getting error unable to pip install slackevents api due to os error. Access denied consider using '--user' i have got can anyone please help thankyou in advance
@NorbertMoutier
@NorbertMoutier 3 года назад
Trying for hours but doesnt seems to work. Badgateway from ngrok, slack dont want my url... i have no idea of what to do...
@LindaVivah
@LindaVivah 3 года назад
Same thing happened to me. Are you using vscode editor? I fixed it by running my code locally once (the play button on vs code) & then the ngrok server command in the command line returned 200. Hope that helps!
@anupakulathunga345
@anupakulathunga345 3 года назад
Your URL didn't respond with the value of the challenge parameter. I got this error please help😥
@TheGifton36
@TheGifton36 2 года назад
did you solved it?
@iMDM_
@iMDM_ 4 года назад
At the end of the video you didnt blur token in payload)))
@krystlertabinas3151
@krystlertabinas3151 7 месяцев назад
Hi how do i add custom buttons?
@orcahomes3232
@orcahomes3232 3 года назад
Hi Tim! Can you build a slack bot for us?
@cosminvalentinionita5743
@cosminvalentinionita5743 4 года назад
Post some more in depth js pls
@Nuns341
@Nuns341 2 года назад
slack.errors.SlackApiError: The request to the Slack API failed. The server responded with: {'ok': False, 'error': 'invalid_arguments', 'response_metadata': {'messages': ['[ERROR] must provide a string [json-pointer:/channel]']}} I keep getting this error
@kevinkennethp995
@kevinkennethp995 2 года назад
check your api key
@noah77
@noah77 4 года назад
Ello Tim
@bennouisser1350
@bennouisser1350 6 месяцев назад
ngrok is not free anymore D:
@sallowkimberly2350
@sallowkimberly2350 4 года назад
hello Tech with Tim my code raises a key error like this File "C:/Users/Administrator/bot.py/main.py", line 9, in client: WebClient = slack.WebClient(token=os.environ['SLACK_TOCKEN']) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\os.py", line 669, in __getitem__ raise KeyError(key) from None KeyError: 'SLACK_TOCKEN' what i do then
@AMWstyles
@AMWstyles 2 года назад
Did u find an answer for this? Having the same issue
@fadliaidin262
@fadliaidin262 4 года назад
I'm here as a beginner
@Converxful
@Converxful 3 года назад
HELP! :D Hey! Very nice video, but my bot is a little bit stubborn.. :D When I post message in (private channel - yeah I have adjusted its oauth / events so it could read private), it still repeats the message (EVEN WITH THAT IF STATEMENT), slack sends it to my flask twice from the user and twice from the bot. :/ Any solution for such shit?
@Converxful
@Converxful 3 года назад
Solved it this way, but I don't like it, its still bombing me with POST requests when noone asked for it :D msg_id = [] @slack_event_adapter.on('message') def message(payload): event = payload.get('event', {}) channel_id = event.get('channel') user_id = event.get('user') text = event.get('text') mid = event.get('client_msg_id') if user_id != BOT_ID: msg_id.append(mid) count = msg_id.count(mid) if count
@blackboxbs8642
@blackboxbs8642 3 года назад
@@Converxful i had the samw glitch what could be the problem?
@areg_arzumanyan
@areg_arzumanyan 2 года назад
It doesn't work. I checked everything but haven't found a mistake. Please heeeelp!
@lilchief2823
@lilchief2823 3 года назад
there is a better way to do this using uptime
@avigupta6064
@avigupta6064 4 года назад
Where's Django's Spotify API tutorial? Waiting from the past 1 month
@ahmedthegreat3973
@ahmedthegreat3973 4 года назад
14th Comment Thats Great
@zabbix3441
@zabbix3441 3 года назад
De donde puedo sacar la lista de los event.get() ?
@lemonadesoda3084
@lemonadesoda3084 4 года назад
second!
@mshimanshu1000
@mshimanshu1000 4 года назад
hey anyone here who is learning python ?
Далее
Python Slack Bot Tutorial #3 - Slash Commands
12:47
Просмотров 47 тыс.
Python Slack Bot Tutorial #1 - Setup & Sending Messages
14:41
Find The Real MrBeast, Win $10,000
00:37
Просмотров 22 млн
Мои РОДИТЕЛИ - БОТАНЫ !
31:36
Просмотров 487 тыс.
The most important Python script I ever wrote
19:58
Просмотров 200 тыс.
Создание Slack-бота на Python
1:15:08
Просмотров 9 тыс.
How To Make Money From Coding - A Complete Guide
43:05
Просмотров 136 тыс.
Building Slack AI Assistants with Python & LangChain
28:31
Build Anything with Llama 3 Agents, Here’s How
12:23
Просмотров 146 тыс.
An Introduction to Software Design - With Python
34:05
Просмотров 516 тыс.
How I make bots using python (educational)
17:12
Просмотров 549 тыс.