This slackbot is written in python, using AWS Chalice to configure AWS Lambda and API Gateway automatically. Project uses Upstash Redis for database.
Commands:
/event set birthday <YYYY-MM-DD> <user> :
/event set anniversary <YYYY-MM-DD> <user> :
/event set custom <YYYY-MM-DD> <user> <any kind of message with whitespaces> :
/event get-all birthday :
/event get-all anniversary :
/event get-all custom :
/event get birthday <user> :
/event get anniversary <user> :
/event get custom <event_name>(can be found with get-all) :
/event remove birthday <user> :
/event remove anniversary <user> :
/event remove custom <event_name>(can be found with get-all) :
If a single user is mentioned while setting the event:
Go to the Upstash Console and create a new database
Find the variables in the database details page in Upstash Console:
UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN
(These will be the env variables for chalice deployment)
May need to revise permissions and what not
SLACK_SIGNING_SECRET:
SLACK_BOT_TOKEN:
(Taken from Official Chalice Repo. You can refer for more info there.)
$ mkdir ~/.aws
$ cat >> ~/.aws/config
[default]
aws_access_key_id=YOUR_ACCESS_KEY_HERE
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
region=YOUR_REGION (such as us-west-2, us-west-1, etc)
Install chalice if not installed:
pip install chalice
Create chalice project by running:
chalice new-project <project-name>
Configure config.json file inside the .chalice directory by adding:
"environment_variables": {
"UPSTASH_REST_URL": <UPSTASH_REDIS_REST_URL>,
"UPSTASH_TOKEN": <UPSTASH_REDIS_REST_TOKEN>,
"SLACK_BOT_TOKEN": <SLACK_BOT_TOKEN>,
"SLACK_SIGNING_SECRET": <SLACK_SIGNING_SECRET>,
"NOTIFY_TIME_LIMIT": "<amount of days before getting notifications for events>"
}
To run locally:
chalice local
Using services such as ngrok, tunnel the relevant port, then use the public domain for Slack.
chalice deploy
Use the REST API URL for Slack.
REST API URL.event<REST_API_URL>After these changes, Slack may require reinstalling of the app.
26 followers · starred Mar 2022
This slackbot is written in python, using AWS Chalice to configure AWS Lambda and API Gateway automatically. Project uses Upstash Redis for database.
Commands:
/event set birthday <YYYY-MM-DD> <user> :
/event set anniversary <YYYY-MM-DD> <user> :
/event set custom <YYYY-MM-DD> <user> <any kind of message with whitespaces> :
/event get-all birthday :
/event get-all anniversary :
/event get-all custom :
/event get birthday <user> :
/event get anniversary <user> :
/event get custom <event_name>(can be found with get-all) :
/event remove birthday <user> :
/event remove anniversary <user> :
/event remove custom <event_name>(can be found with get-all) :
If a single user is mentioned while setting the event:
Go to the Upstash Console and create a new database
Find the variables in the database details page in Upstash Console:
UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN
(These will be the env variables for chalice deployment)
May need to revise permissions and what not
SLACK_SIGNING_SECRET:
SLACK_BOT_TOKEN:
(Taken from Official Chalice Repo. You can refer for more info there.)
$ mkdir ~/.aws
$ cat >> ~/.aws/config
[default]
aws_access_key_id=YOUR_ACCESS_KEY_HERE
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
region=YOUR_REGION (such as us-west-2, us-west-1, etc)
Install chalice if not installed:
pip install chalice
Create chalice project by running:
chalice new-project <project-name>
Configure config.json file inside the .chalice directory by adding:
"environment_variables": {
"UPSTASH_REST_URL": <UPSTASH_REDIS_REST_URL>,
"UPSTASH_TOKEN": <UPSTASH_REDIS_REST_TOKEN>,
"SLACK_BOT_TOKEN": <SLACK_BOT_TOKEN>,
"SLACK_SIGNING_SECRET": <SLACK_SIGNING_SECRET>,
"NOTIFY_TIME_LIMIT": "<amount of days before getting notifications for events>"
}
To run locally:
chalice local
Using services such as ngrok, tunnel the relevant port, then use the public domain for Slack.
chalice deploy
Use the REST API URL for Slack.
REST API URL.event<REST_API_URL>After these changes, Slack may require reinstalling of the app.
26 followers · starred Mar 2022