slack-pd-bot

command module
v1.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 14 Imported by: 0

README

slack-pd-bot

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 Screenshot 4 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

  1. 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.
  2. 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.
  3. To get started, obtain Slack Tokens and PagerDuty token by following the steps below.
  4. 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.
  5. Create the PagerDuty token by referring to the PagerDuty documentation on API access keys.
  6. 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

  1. To run the code, simply call the main.go file, after updating the tokens
  2. 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
Screenshot 2023-07-08 at 424 38 PM
using bot to give Slack input
Screenshot 2023-07-08 at 44 38 PM
oncall schedule in PagerDuty

Screenshot 3

As you can see on making the query in slack the bot returned the user who's on call for that team.

TODO

  1. Helmify the app so it can be deployed in Kubernetes.
  2. Add more features like schedule on-call, schedule overrides, and add/create teams using Slack commands.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL