Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions docs/integrations/apis/slack-tasks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Slack tasks
sidebarTitle: Tasks
---

Tasks are executed after the job is triggered and are the main building blocks of a job. You can string together as many tasks as you want.

---

## All tasks

### `postMessage`

Post a message to a channel. [Official Slack Docs](https://api.slack.com/methods/chat.postMessage)

```ts example.ts
// Send a Slack message using the io.slack.postMessage function
const response = await io.slack.postMessage("post message", {
// Specify the target channel by providing its ID
channel: "< your-channel-id >",
// Set the text content of the message
text: "My first Slack message",
});

```
## Example Usage

```ts
client.defineJob({
id: "slack-test",
name: "Slack test",
version: "0.0.1",
trigger: eventTrigger({
name: "slack.test",
schema: z.object({}),
}),
integrations: {
slack,
},
run: async (payload, io, ctx) => {
const response = await io.slack.postMessage("post message", {
channel: "C04GWUTDC3W",
text: "My first Slack message",
});
},
});
```

56 changes: 28 additions & 28 deletions docs/integrations/apis/slack.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
---
title: Slack
title: Slack overview & authentication
sidebarTitle: Overview & authentication
---

<Snippet file="integration-getting-started.mdx" />
## Overview

Our Slack integration provides a powerful way to streamline communication and workflows within your organization, making it easier to stay informed, collaborate efficiently, and automate routine tasks.

You can tailor triggers and tasks to your specific needs, ensuring that your team and processes are more productive and responsive.

For examples of some of the things you can do with it, check out our Jobs Showcase:

<Card
title="Jobs Showcase - Slack"
icon="rocket"
href="https://trigger.dev/showcase?tags=&integrations=slack"
>
Check out pre-built Slack jobs in our showcase.
</Card>

## Installation

Expand All @@ -26,39 +41,24 @@ yarn add @trigger.dev/slack@latest

Slack supports OAuth

## OAuth

To use OAuth you can connect to Slack via the Trigger.dev [web app](https://cloud.trigger.dev). Click 'Integrations' in the side panel of any project, and configure Slack with the ID you want to use in your job and the required [scopes](https://api.slack.com/scopes).

```ts
import { Slack } from "@trigger.dev/slack";

const slack = new Slack({
id: "slack",
});
```
## Tasks

## Example

```ts
client.defineJob({
id: "slack-test",
name: "Slack test",
version: "0.0.1",
trigger: eventTrigger({
name: "slack.test",
schema: z.object({}),
}),
integrations: {
slack,
},
run: async (payload, io, ctx) => {
const response = await io.slack.postMessage("post message", {
channel: "C04GWUTDC3W",
text: "My first Slack message",
});
},
});
```
Once you have set up a Slack client, you can use it to create tasks.

## Tasks
<CardGroup>
<Card title="Tasks" icon="sparkles" href="/integrations/apis/slack-tasks">
Perform tasks such as posting message to a channel.
</Card>
</CardGroup>

| Function Name | Description |
| ------------- | --------------------------- |
| `postMessage` | Post a message to a channel |
8 changes: 7 additions & 1 deletion docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,13 @@
"integrations/apis/replicate",
"integrations/apis/resend",
"integrations/apis/sendgrid",
"integrations/apis/slack",
{
"group": "Slack",
"pages": [
"integrations/apis/slack",
"integrations/apis/slack-tasks"
]
},
"integrations/apis/stripe",
{
"group": "Supabase",
Expand Down