60 lines
1.2 KiB
Plaintext
60 lines
1.2 KiB
Plaintext
---
|
|
title: "Slack"
|
|
sidebarTitle: "Slack"
|
|
description: "Here are some example workflows you could create using the Slack integration."
|
|
---
|
|
|
|
To use the Slack integration you must first install the required packages:
|
|
|
|
<Tabs>
|
|
<Tab title="npm">
|
|
|
|
```bash
|
|
npm install @trigger.dev/slack
|
|
```
|
|
|
|
</Tab>
|
|
<Tab title="pnpm">
|
|
|
|
```bash
|
|
pnpm install @trigger.dev/slack
|
|
```
|
|
|
|
</Tab>
|
|
<Tab title="yarn">
|
|
|
|
```bash
|
|
yarn add @trigger.dev/slack
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
## Post to Slack when a GitHub issue is created or modified
|
|
|
|
Integrations required: Slack, GitHub
|
|
|
|
```ts
|
|
import { Trigger, customEvent } from "@trigger.dev/sdk";
|
|
import * as slack from "@trigger.dev/slack";
|
|
import * as github from "@trigger.dev/github";
|
|
import { z } from "zod";
|
|
|
|
new Trigger({
|
|
id: "my-workflow-1",
|
|
name: "Posts to Slack when GitHub Issue created or modified",
|
|
apiKey: "<my_api_key>",
|
|
on: github.events.issueEvent({
|
|
repo: "my-github-org/my-github-repo",
|
|
}),
|
|
run: async (event, ctx) => {
|
|
const response = await slack.postMessage("send-to-slack", {
|
|
channelName: "my-slack-channel-name",
|
|
text: `A new issue has been created or modified. ${event.action}`,
|
|
});
|
|
|
|
return response.message;
|
|
},
|
|
}).listen();
|
|
```
|