🎉 Announcing our $3 million seed round
Getting Started

Slack Notifications

Only available in OpenMeter Cloud
Sign Up

OpenMeter webhooks enable you to send Slack notifications about your customer's consumption. This is done via our webhook provider, Svix's Slack integration and webhook transformation.

Setting up the Slack integration

To set up the Slack integration, visit the Svix dashboard from OpenMeter Cloud UI. On the Svix dashboard, click Add Endpoint -> Transformation template -> Report Usage to Slack.

On the endpoint creation page, connect your Slack account and pick a Slack channel. Then, choose the meter.report event type. Under the channels, you can also subscribe to specific OpenMeter reports instead of listening to all.

Webhook Transformation

Optionally, you can modify the default transformation code to customize the Slack notification. The default transformation includes the usage value for the meter and the time range of the report in the Slack message.

The default Slack message looks as:

OpenMeter Architecture

And the default transformation code producing it is:

function handler(webhook) {
  const subject = webhook.payload.query.subject;
  const meter = webhook.payload.meter.slug;
  const from = webhook.payload.query.from;
  const fromUnix = Math.round(new Date(from).getTime() / 1000);
  const fromStr = `<!date^${fromUnix}^{date} at {time}|${from}>`;
  const to = new Date(webhook.payload.query.to);
  const toUnix = Math.round(new Date(to).getTime() / 1000);
  const toStr = `<!date^${toUnix}^{date} at {time}|${to}>`;
  const value = webhook.payload.usage[0].value;
  webhook.payload = {
    text: `\`${subject}\` value for meter \`${meter}\` is \`${value}\` between \`${fromStr}\` and \`${toStr}\`.`,
  return webhook;

To learn more about webhook transformations, please read Svix's documentation.

Last edited on June 24, 2024