simple Slack BOT tutorial
some tutorials on google.com would be different with this tutorial since it different client
- Set up python environment
python -m venv slack-env
pip install -r requirements.txt
- Sign up ngrok to setup local machine as server
- because we need local server that subscriptions to slack event
- Create a slack bot on website to get token
- Install an
@lazyawsbot
to workspace - Setup slack bot token
- depend on your OS then set a token inside script file and execute
Let's start with simple.py which is a hello world message
- Add permission for bot to join channel
channels:join
andchat:write
- Invite chat bot to
general
channel via mention@lazyawsbot
- run
python .\simple.py
Expected you should have Hello World!
message in channel
is a WebSocket-based API that allows you to receive events from Slack in real time and send messages as users
- On VSCode to run with
Simple RTM
debugger mode - Use ngrok to make a web server tunnel on
ngrok http 3000
- Grab
ngrok_url + /slack/events
and register on Event Subscriptions page in api slack- subscribe bot events with
message.channels
- subscribe bot events with
- Add
@lazyawsbot
into #General - Type
Hello World
and wait for response
A bot that have abilities to queries EC2 instance name on AWS
- AWS Cli
pip install awscli
- AWS User
- Add permission for Administrator API Gateway and Lambda
- setup AWS cli with
aws configuration
- Run AWS scripts to generate API gateway
- Tracking conversations
- in complex bot we need to interact with bot in multiple conversation
- create a db for keep database identities and manage business logic
- and removed from the db/memory list if it not continue conversation
- Threaded messages
- bot will still receive message events for these threaded
- bot need to reply to correct in the relevant location