This is a basic of how to integrate git API's into a slack bot.
- Pull a list of open pull requests for a given git organization.
- slackbot_git_bot.py: Source code for the slack bot
- github_integration.py: Source code responsible for making the git call to github
- configs.py: Confings used for auth
- requirements.txt: List of requirements for the project
In order for this slack bot to work it will need a few keys to authenticate to slack, the contents of the config file as well as what they are can be found below.
{
"slack_bot_token":"",
"git_hub_key": "",
"git_hub_org": "",
"git_hub_repo_list": ["",""]
}
- slack_bot_token: This is the token of the bot user configured in slack
- git_hub_key: This is a developer key used to auth into git
- git_hub_org: This is the name of the org you wish to monitor
- git_hub_repo_list: This is an array containing the repos you want to check for open pull requests
At a high level, the steps you will need to take to get this set up are listed below. If you want a more comprehensive walk through, please check out the youtube link below.
- Create an application in slack
- Add a bot user to the slack application
- Enable OAuth for the bot user
- Grant the bot user chat:write:bot scope
- Copy the slack bot token to the configs.json file
- Add in the org name, git token, and repo names into the configs.json
- In a terminal session launch the slack bot
- Type 'pull requests' into slack