Download - ATX Bot Talk - Hello PyBot
![Page 1: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/1.jpg)
Hello PyBotPython Chat Bots for Slack
github.com/jeffk/PyBot
Jeff Kramer (@jeffk) ~ Data Infrastructure @ Vox Media
![Page 2: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/2.jpg)
Users
Turing’s Magic Matrix
PassBots
Pass
Fail
![Page 3: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/3.jpg)
![Page 4: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/4.jpg)
Incoming Web Hooks• Unique URLs • JSON Payloads
• Custom Names/Icons/Chan
curl -X POST —data-urlencode 'payload={ "text": "This is posted to <#general> and comes from *monkey-bot*.", "channel": "#general", "username": "monkey-bot", "icon_emoji": “:monkey_face:"}' https://hooks.slack.com/services/T00/B000/XXXXXX
![Page 5: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/5.jpg)
Outgoing Web Hooks• Channel and/or Trigger Words
(Public-Only) • HTTP Post, JSON Resp
token=XXXXXXXXXXXXXXXXXX team_id=T0001 team_domain=example channel_id=C2147483705 channel_name=test timestamp=1355517523.000005
user_id=U2147483697 user_name=Steve text=googlebot: What is the air-speed velocity of an unladen swallow? trigger_word=googlebot:
{ "text": "African or European?” }
![Page 6: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/6.jpg)
/Slash Commands• POST or GET • Response Only Shown to User
It’s San Francisco, ergo cold.
token=gIkuvaNzQIHg97ATv team_id=T0001 team_domain=example channel_id=C2147483705 channel_name=test
user_id=U2147483697 user_name=Steve command=/weather text=94103
![Page 7: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/7.jpg)
Other Integrations
• Web API (OAUTH, HTTP RPC) • IRC/XMPP/LOL/SOB
![Page 8: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/8.jpg)
The Slack Real Time Messaging API
• WebSockets
• Used by all Slack Clients
• Pushed All Messages in All Channels
• Commonly Used with Bot Users
• Can’t Join Channels
• Always Active (Unless set)
![Page 9: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/9.jpg)
![Page 10: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/10.jpg)
Real Time WebSockets Examples
![Page 11: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/11.jpg)
Frameworks & Wrappers• python-rtmbot
• Uses SlackClient
• Supports Plugins
• api.slack.com/community#python
• err - Popular Chatbot w/Slack Support
• butterfield - Uses asyncio
• slacker - Popular Wrapper
![Page 12: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/12.jpg)
Scaling Up
• Connection Proxies/Message Brokers (Relax)
• Task Queues (Celery)
• Sharding
![Page 13: ATX Bot Talk - Hello PyBot](https://reader031.vdocuments.mx/reader031/viewer/2022021814/58f130c51a28abc90a8b4611/html5/thumbnails/13.jpg)
Resources
github.com/slackhq/python-slackclient & python-rtmbot
@jeffk jeffkramer.com github.com/jeffk/PyBot
dev4slack.xoxco.com api.slack.com/web api.slack.com/community