Slack
Message
typescriptCopied1import airplane from "airplane";23export default airplane.task(4{5slug: "send_slack_notifs",6},7async () => {8await airplane.slack.message("#my-channel", "Hello world");9// Sends message to user with Slack ID U0G9QF9C6.10await airplane.slack.message("U0G9QF9C6", "Hello world");11// Sends message using Slack's Block Kit API.12await airplane.slack.message("#my-channel", {13blocks: [14{15type: "section",16text: {17type: "mrkdwn",18text: "Task created by <example.com|Fred Enriquez> has completed\n\n<https://example.com|View task>",19},20},21],22});23},24);
The Slack channel to send messages to. channelName
also accepts a Slack channel ID or Slack user ID (for direct messages).
Contents of the message. message
is a string that can be formatted using Slack markdown. message
also support more advanced formatting like @-mentioning, date formatting, etc. To learn more, see the Slack formatting docs. For more control (e.g. to use Block Kit), message
can also be an object of Slack postMessage arguments.
Output
pythonCopied1import airplane23@airplane.task()4def send_slack():5airplane.slack.message("#my-channel", "Hello world")6# Sends message to user with Slack ID U0G9QF9C6.7airplane.slack.message("U0G9QF9C6", "Hello world")8# Sends message using Slack's Block Kit API.9airplane.slack.message("#my-channel", airplane.slack.MessageOption(10blocks=[11{12"type": "section",13"text": {14"type": "mrkdwn",15"text": "Task created by <example.com|Fred Enriquez> has completed\n\n<https://example.com|View task>",16},17},18],19))
Request
The Slack channel to send messages to. channelName
also accepts a Slack channel ID or Slack user ID (for direct messages).
Contents of the message. message
is a string that can be formatted using Slack markdown. message
also support more advanced formatting like @-mentioning, date formatting, etc. To learn more, see the Slack formatting docs. For more control (e.g. to use Block Kit), message
can also be an object of Slack postMessage arguments.
Whether or not to omit leading whitespace from message
.
Output
If the prompt cannot be created properly.
If the run fails or is cancelled.
Upload
typescriptCopied1import airplane from "airplane";23const CSV_TEXT = `Name,Email,Phone,JoinDate4John Doe,john@airplane.dev,123-456-7890,2021-03-14`;56/** Uploads a CSV string to #my-channel. */7export const uploadCSV = airplane.task({ slug: "upload_csv" }, async () => {8await airplane.slack.upload("#my-channel", {9payload: CSV_TEXT,10filename: "employees.csv",11message: "Here are our employees.",12});13});1415/** Uploads an image passed in the task param to user with Slack ID U0G9QF9C6. */16export const uploadImage = airplane.task(17{18slug: "upload_file_to_slack",19parameters: { image: { type: "upload" } },20},21async (params) => {22await airplane.slack.upload("U0G9QF9C6", {23payload: params.image,24filename: "image.png",25message: "Here's my uploaded image.",26});27},28);
The Slack channel to send notifications to. channelName
also accepts a Slack channel ID or Slack user ID (for direct messages).
The options to use when uploading the file.<br/>The options include the payload, filename, and an optional message. The payload is the file that is uploaded to Slack. The filename is the name of the upload and is also used to determine the file type of the payload.
Output
pythonCopied1import airplane23CSV_TEXT = """Name,Email,Phone,JoinDate4John Doe,john@airplane.dev,123-456-7890,2021-03-14"""567@airplane.task()8def upload_csv():9"""Uploads a CSV string to #my-channel."""10airplane.slack.upload(11"#my-channel", CSV_TEXT, "my-file.csv", "Here are our employees."12)131415@airplane.task()16def upload_image(image: airplane.File):17"""Uploads an image passed in the task param to user with Slack ID U0G9QF9C6."""18airplane.slack.upload("U0G9QF9C6", image, "image.png", "Here's my uploaded image.")
The Slack channel to send notifications to. channelName
also accepts a Slack channel ID or Slack user ID (for direct messages).
The file that's uploaded to Slack.
The name of the upload. This is also used to determine the file type of the file.
Optional message to include with the upload.
Output
If the prompt cannot be created properly.
If the run fails or is cancelled.