blck-snwmn / slackworker

A cf worker that consume messages from the queue and notifies Slack.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

slackworker

Deploy CodeQL

A worker that consume messages from the queue and notifies Slack.

Setting(for Local)

  1. Create a file named .dev.vars in the project root directory.
  2. Write the following key-value pairs in the .dev.vars file:
SLACK_TOKEN=<Your_SLACK_TOKEN>

Replace

  • '<Your_Slack_Bearer_Token>' with the bearer token for the Slack file upload API

Setting

Run the following commands to add your secrets to the Workers configuration:

secret

wrangler secret put SLACK_TOKEN

queues

wrangler queues create slackqueue

Deploy

After you've added the secrets, deploy the Worker with the following command:

wrangler deploy

Use

Send to queue from cf worker(note: Queues is open beta)

Add the following to your wrangler.toml

[[queues.producers]]
queue = "slackqueue"
binding = "SLACK_NOTIFIER"

Add the following to your worker script

export interface Env {
	SLACK_NOTIFIER: Queue;
}
...
await env.SLACK_NOTIFIER.send({
    type: "chat.postMessage",
    body: {
        channel: "your channel id"
        text: "Hello, world!", // or blocks
    },
});

Tail worker(note: Tail Workers is open beta)

Add the following to your wrangler.toml

tail_consumers = [{service = "slackworker"}]

About

A cf worker that consume messages from the queue and notifies Slack.


Languages

Language:TypeScript 100.0%