// Send a Slack message using the io.slack.postMessage functionawait 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: "<your-slack-message>",});
If we don’t have the task you need listed above, you can use io.slack.runTask() function, which lets you do anything that’s possible with the official Slack Node SDK. More information here.Example usage:
Copy
Ask AI
client.defineJob({ id: "send-slack-message", name: "Send a Slack message", version: "1.0.0", trigger: eventTrigger({ name: "send.slack.message", schema: z.object({ message: z.string, }), }), integrations: { slack, }, run: async (payload, io, ctx) => { // Use the Slack integration to create a task using the "post-message" cacheKey const message = await io.slack.postMessage("post-message", { channel: process.env.SLACK_CHANNEL_ID, message: payload.message, }); // Use the Slack integration's runTask method to add a reaction to the message await io.slack.runTask("add-reaction", async (client) => { // client here is an authenticated instance of the Slack SDK await client.reactions.add({ channel: process.env.SLACK_CHANNEL_ID, name: "thumbsup", timestamp: message.ts, }); }); },});