This examples shows how to build a simple app that sends a message via Slack after receiving a webhook request sent by Blockfrost. It implements webhook endpoint and integrates with Slack API to send a message to a Slack workspace.
To learn more about Secure Webhooks, see Secure Webhooks Docs.
This example is written in Typescript and it is intended to run on Node.js, not in a browser. Follow the instructions below to run it.
These instructions assume that you already have Node.js installed and you are already familiar with running hello world on Node.js.
Create a slack app and generate Bot User OAuth Token by following Slack: Basic app setup. Don't forget to invite the app bot to a channel where you want to send messages.
SECRET_AUTH_TOKEN
- You will find your webhook's secret auth token in your Secure Webhook settings in the Blockfrost DashboardPORT
- port for the web server (default6666
)SLACK_BOT_TOKEN
- Slack Bot User OAuth Token (xob-...
). You can find it under "OAuth & Permissions" section of Slack App settingsSLACK_CHANNEL_ID
- ID of the Slack channel where to send a notification
Clone the main Blockfrost examples repository
git clone [email protected]:blockfrost/blockfrost-js-examples.git
Change directory to cloned repository blockfrost-js-examples
cd blockfrost-js-examples
Install dependencies
yarn
Run
yarn workspace @blockfrost/example-webhook-slack start