Skip to content

Syncs one or more PagerDuty on-call schedules to a Slack channel topic

License

Notifications You must be signed in to change notification settings

get-convex/pagerduty-slack-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pagerduty Slack Sync

Syncs one or more PagerDuty on-call schedules to a Slack channel topic using a Convex backend.

image

Initial Setup

Run npx convex dev --once to initialize a Convex project for this code.

Open the dashboard with npx convex dashboard to access your dev deployment.

Under "Settings" -> "Environment Variables", set PAGERDUTY_API_KEY with an API v2 Key and SLACK_API_KEY with an Integrated Bot key. Ensure the bot has been invited to the channel(s) whose topic you'd like to update.

Optionally, set the DRY_RUN variable to a non-empty value to prevent an actual update of the topic; the proposed update will be logged instead. Note that you will need to repeat this process for your production deployment with the appropriate values.

Run npx convex dev to continuously deploy your code as you change it.

Adding schedules and channels

The sync function should be running once per minute now, but without any channels or schedules configured, it will have no work to do.

To add a new configuration entry, go to the data tab on your deployment's dashboard and add a new document to the configs table. See convex/schema.ts for the document schema.

For example, one could add the following document:

{
  channel: "<slack channel ID>",
  schedules: [
    { name: "Primary", schedule: "<PagerDuty Schedule ID>" },
    { name: "Secondary", schedule: "<PagerDuty Schedule ID>" },
  ],
}

The channel topic will be updated to match the following format:

Primary: <Primary On-call>, Secondary: <Secondary On-call>, [<Schedule Name>: <Scheduled On-call>, ...] | <Previous topic content>

Getting Slack and PagerDuty IDs

To get a Slack channel ID, right click on the channel name and copy a link to the channel. It will be of the format https://<workspace>.slack.com/archives/<Channel ID>.

To get a PagerDuty Schedule ID, go to the on-call schedule and look for the URL to be in the format https://<organization>.pagerduty.com/schedules/<Schedule ID>

Prod vs. Dev

In Convex, a project has one Prod backend, and a Dev backend per developer.

If you want multiple teammates to be able to edit the code or environment variables, you can use the Prod instance.

To do this, run npx convex deploy, and set the environment variables there as in dev.

Note: Your dev instance will continue to sync changes as well, unless you stop it. You can stop it by:

What is Convex?

Convex is a hosted backend platform with a built-in database that lets you write your database schema and server functions in TypeScript. Server-side database queries automatically cache and subscribe to data, powering a realtime useQuery hook in our React client. There are also Python, Rust, ReactNative, and Node clients, as well as a straightforward HTTP API.

The database supports NoSQL-style documents with relationships, custom indexes (including on fields in nested objects) and vector search.

The query and mutation server functions have transactional, low latency access to the database and leverage our v8 runtime with determinism guardrails to provide the strongest ACID guarantees on the market: immediate consistency, serializable isolation, and automatic conflict resolution via optimistic multi-version concurrency control (OCC / MVCC).

The action server functions have access to external APIs and enable other side-effects and non-determinism in either our optimized v8 runtime or a more flexible node runtime.

Functions can run in the background via scheduling and cron jobs.

Development is cloud-first, with hot reloads for server function editing via the CLI. There is a dashbord UI to browse and edit data, edit environment variables, view logs, run server functions, and more.

There are built-in features for reactive pagination, file storage, reactive search, https endpoints (for webhooks), streaming import/export, and runtime data validation for function arguments and database data.

Everything scales automatically, and it’s free to start.

About

Syncs one or more PagerDuty on-call schedules to a Slack channel topic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •