A Slack bot written in Golang to interact with PagerDuty. This is a work-in-progress, side project I created over the Independence day week off this July 2023, and I'm sharing the first iteration for feedback loop only.(I use semantic_version to keep track of release)
Introduction
This project was created out of a requirement to use Chatops to manage incident and interact with incident response management tool like PagerDuty. The functions and usecase of this bot is similar to Hubot or Pagerly or Errbot, but in a lightweight model for anyone to get started.
Installation
Currently, the code only supports fetching the person who is on-call for a team from PagerDuty. More PagerDuty features will be added to the bot in the future. If you would like to add any features, please mention them in the GitHub issues.
The Helm chart for deploying this bot as a service in Kubernetes is currently in progress and will be shared eventually, currently this needs to be run in local.
To get started, obtain Slack Tokens and PagerDuty token by following the steps below.
Thanks to this blog from Sourabh Chakravarty for providing insights on creating Slack tokens. Please follow the instructions in the blog to create a Slack app and obtain the required auth tokens.
Create the PagerDuty token by referring to the PagerDuty documentation on API access keys.
Add the Slack tokens and PagerDuty token to the .env file. We use the godotenv module to fetch the tokens as environment variables. If the app is deployed to Kubernetes, expose the tokens in secrets. (Steps to deploy this as a service in Kubernetes will be added in the next iteration of this code.)
Running the Code in local
To run the code, simply call the main.go file, after updating the tokens
In Slack, call "@botname devops oncall". This will return the person who's on call for that team. Please refer to the attached snapshots for reference.
Attached Snapshots
Running the code
using bot to give Slack input
oncall schedule in PagerDuty
As you can see on making the query in slack the bot returned the user who's on call for that team.
TODO
Helmify the app so it can be deployed in Kubernetes.
Add more features like schedule on-call, schedule overrides, and add/create teams using Slack commands.