← Back to Recipes

Post chart to Slack daily

Use a cron job or GitHub Actions to render a chart and post to Slack.

import { ChartOutput } from '@chart-output/node';
import { WebClient } from '@slack/web-api';

const client = new ChartOutput({ apiKey: process.env.CHART_OUTPUT_API_KEY });
const chartPng = await client.renderTemplate('mrr-trend', {
  data: [12000, 15000, 18000],
});

const slack = new WebClient(process.env.SLACK_BOT_TOKEN);
await slack.files.upload({
  channels: '#metrics',
  file: chartPng,
  title: 'Daily MRR',
});