This bot wishes your team mates on their birthdays on Slack. It can send a message to a Slack channel of your choosing. You can even mention the user and send a custom greeting message.
The bot is designed to run as a cron
job. It has no dependencies on any external packages. It is also designed to work with both python versions - 2 and 3.
- Configure an Incoming Webhook URL on Slack
- Make a copy of the
birthdays.example.json
file naming it tobirthdays.json
. - Populate your birthdays database with the birthdays of your team members.
- NB : You can either use their real names or their usernames. Just remember to configure the mention configuration correctly.
- Make a copy of the
configurations.json.example
file naming itconfigurations.json
. Update the configuration values according to your preferences
{
"birthdays_path" : "birthdays.json", # you may change the database filename
# according to your preference.
"mention" : <true | false>, # depends on your database configuration format
# if you're using real names, set this value to false
# if you're using usernames, set this value to true
"slack_url" : "https://hooks.slack.com/...", # the webhook URL you configured in step 1.
"channel_name" : "<channel_name>", # the channel you want your wishes to be sent to
"greeting_message" : "Happy birthday!" # the wish you would like the bot to send
"bot_name" : "Birthday Bot" # the name of the bot sending the wish
"bot_emoji" : ":tada:" # the emoji the bot should use as it's icon
}
- Run
crontab -e
to edit your crontab - Add this line to the crontab and save it:
@daily cd /clone/location && python Birthday-slackbot.py
- replace
/clone/location
with the location where you cloned the repo) - the
@daily
cron
shorthand might vary among servers and/or distributions. Replace@daily
with a time of your preference according to thecron
syntax. - Remember to verify the timezone setting of your server or you won't get the expected result.
- replace
This script was originally written in Ruby from which @shinenelson ported it into Python. The reasoning behind the port was to reduce the barriers to entry for deployment. A python runtime is generally available on *NIX-based systems out-of-the-box making it easier to deploy with minimal effort compared to Ruby which would require a ruby runtime to be installed on the system the script is being deployed on. The idea was to get it running with no dependency installs ( whatsoever ).
This script is released into the public domain. See the attached LICENSE file for more information.
Good job @shinenelson 👏