The new Slack platform and the features described below are in beta and under active development.

Built-in types

Type Kind Description
Schema.types.string String UTF-8 encoded string, up to 4000 bytes
Schema.types.boolean Boolean A logical value, must be either true or false
Schema.types.array Array An array of items (based on a type that you specify)
Schema.types.object Object A custom Javascript object, like {"site": "slack.com"}
Schema.types.integer Integer A whole number, such as -1, 0, or 31415926535
Schema.types.number Number A number that allows decimal points such as 13557523.0005
Schema.slack.types.user_id Slack User ID A Slack user ID such as U123ABC456 or W123ABC456
Schema.slack.types.channel_id Slack Channel ID A Slack channel ID such as C123ABC456 or D123ABC456
Schema.slack.types.usergroup_id Slack User Group ID A Slack channel ID, such as S123ABC456
Schema.slack.types.timestamp Integer The number of seconds elapsed since the UNIX epoch
Schema.slack.types.blocks Slack Blocks An object that contains layout and style information about your message
Schema.slack.types.interactivity Object An object that contains context about the interactive event that led to opening of the form
Schema.slack.types.user_context Object Represents a user who interacted with a workflow at runtime
Schema.slack.types.date String A string containing a date, format is displayed as YYYY-MM-DD
Schema.slack.types.rich_text Object A way to nicely format messages in your app. This type cannot convert other message types e.g. blocks, strings
Schema.slack.types.oauth2 Object The OAuth2 context created after authenticating with external auth

Have 2 minutes to provide some feedback?

We'd love to hear about your experience with the new Slack platform. Please complete our short survey so we can use your feedback to improve.

Strings

Declare a string type:

// ...
{
  name: "notes",
  title: "Notes",
  type: Schema.types.string,
},
// ...
String example

In this example workflow, we use a string type to allow a user to add notes about their time off request.

const ftoRequestData = CreateFTOWorkflow.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: "Request dates off",
    description: "Hooray for vacay!",
    interactivity: CreateFTOWorkflow.inputs.interactivity,
    submit_label: "Submit request",
    fields: {
      elements: [{
        name: "start_date",
        title: "Start date",
        type: Schema.slack.types.date,
      }, {
        name: "end_date",
        title: "End date",
        type: Schema.slack.types.date,
      }, {
        name: "notes",
        title: "Notes",
        description: "Anything to note?",
        type: Schema.types.string,
        long: true, // renders the input box as a multi-line text box on the form
      }],
      required: ["start_date", "end_date"],
    },
  },
);

Boolean

Declare a boolean type:

// ...
isMember: {
  type: Schema.types.boolean,
}
// ...
Boolean example

In this example datastore definition, we use a boolean type to capture whether the message author holds membership in our club.

export const MyDatastore = DefineDatastore({
  name: DATASTORE_NAME,
  primary_key: "id",
  attributes: {
    id: {
      type: Schema.types.string,
    },
    channel: {
      type: Schema.slack.types.channel_id,
    },
    message: {
      type: Schema.types.string,
    },
    author: {
      type: Schema.slack.types.user_id,
    },
    isMember: {
      type: Schema.types.boolean,
    }
  },
});

Array

Declare an array of types:

// ...
{
  name: "departments",
  title: "Your department",
  type: Schema.types.array,
  items: {
    type: Schema.types.string,
    enum: ["marketing", "design", "sales", "engineering"],
    }
  default: ["sales", "engineering"]
 }
// ...
Array example

In this example workflow, we have an array of strings for each department using the enum and choices parameters.

const teammate = NewMemberIntake.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: "Welcome to the team",
    interactivity: NewMemberIntake.inputs.interactivity,
    submit_label: "Submit",
    fields: {
      elements: [{
        name: "department",
        title: "What is your department?",
        type: Schema.types.string,
        enum: ["Marketing", "Design", "Sales", "Engineering"],
        choices: [
          { value: "marketing", title: "Marketing"},
          { value: "design", title: "Design" },
          { value: "sales", title: "Sales" },
          { value: "engineering", title: "Engineering" },
        ],
      }],
      required: ["department"],
    },
  },
);

Object

Declare a custom object type. Refer to custom types for more information.

// ...
properties: {
  reviewer: {
    type: Schema.types.object,
    properties: {
      login: { type: "string" },
    },
  },
}
// ...
Object example

In this example workflow, we notify authors about updates to their file review status.

const ReviewStatusWorkflow = DefineWorkflow({
  callback_id: "review_status_workflow",
  title: "Review status",
  description: "Review status",
  input_parameters: {
    properties: {
      action: {
        type: Schema.types.string,
      },
      review_request: {
        type: Schema.types.object,
        properties: {
          number: { type: "integer" },
          title: { type: "string" },
          body: { type: "string" },
          changed_files: { type: "integer" },
        },
      },
      author: {
        type: Schema.types.object,
        properties: {
          login: { type: "string" },
        },
      },
      reviewer: {
        type: Schema.types.object,
        properties: {
          login: { type: "string" },
        },
      },
    },
    required: ["action", "review_request", "author", "reviewer"],
  },
});

Integer

Declare an integer type:

// ...
  name: "meetings",
  title: "Number of meetings",
  type: Schema.types.integer,
// ...
Integer example

In this example workflow, we check the number of meetings we have scheduled for the day.

const inputForm = MeetingsWorkflow.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: "Number of meetings",
    interactivity: MeetingsWorkflow.inputs.interactivity,
    submit_label: "Check meetings",
    fields: {
      elements: [{
        name: "channel",
        title: "Channel to send results to",
        type: Schema.slack.types.channel_id,
        default: MeetingsWorkflow.inputs.channel,
      }, {
        name: "meetings",
        title: "Number of meetings",
        description: "meetings",
        type: Schema.types.integer,
        minimum: -1,
        maximum: 5,
      }, {
        name: "meetingdate",
        title: "Meeting date",
        type: Schema.slack.types.date,
      }],
      required: ["channel", "meetings", "meetingdate"],
    },
  },
);

Number

Declare a number type:

// ...
{
  name: "distance",
  title: "race distance",
  type: Schema.types.number,
}
// ...
Number example

In this example workflow, we collect a runner's distance and date of their last run.

const inputForm = LogRunWorkflow.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: "Log a run",
    interactivity: LogRunWorkflow.inputs.interactivity,
    submit_label: "Log run",
    fields: {
      elements: [{
        name: "channel",
        title: "Channel to send logged run to",
        type: Schema.slack.types.channel_id,
        default: LogRunWorkflow.inputs.channel,
      }, {
        name: "distance",
        title: "Distance (in miles)",
        type: Schema.types.number,
        description: "race distance (in miles)",
        minimum: 0,
        maximum: 26.2,
      }, {
        name: "rundate",
        title: "Run date",
        type: Schema.slack.types.date,
      }],
      required: ["channel", "distance", "rundate"],
    },
  },
);

User ID

Declare a user_id type:

// ...
{
  name: "runner",
  title: "Runner",
  type: Schema.slack.types.user_id,
}
// ...
User ID example

In this example workflow, we get a runner's ID and the distance of their logged run.

const inputForm = RunWorkflow.addStep(
  Schema.slack.functions.OpenForm,
  {
    title: "Log your run",
    interactivity: RunWorkflow.inputs.interactivity,
    submit_label: "Submit",
    fields: {
      elements: [{
        name: "channel",
        title: "Channel to send entry to",
        type: Schema.slack.types.channel_id,
        default: RunWorkflow.inputs.channel,
      }, {
        name: "runner",
        title: "Runner",
        type: Schema.slack.types.user_id,
      }, {
        name: "distance",
        title: "Distance (in miles)",
        type: Schema.types.number,
      }],
      required: ["channel", "runner", "distance"],
    },
  },
);

Channel ID

Declare a channel_id type:

// ...
  input_parameters: {
    properties: {
      interactivity: {
        type: Schema.slack.types.interactivity,
      },
      channel: {
        type: Schema.slack.types.channel_id,
      },
    },
  }
// ...
Channel ID example

In this example workflow definition, we enable users to send a greeting to a specific channel.

const GreetingWorkflow = DefineWorkflow({
  callback_id: "greeting_workflow",
  title: "Send a greeting",
  description: "Send a greeting to channel",
  input_parameters: {
    properties: {
      interactivity: {
        type: Schema.slack.types.interactivity,
      },
      channel: {
        type: Schema.slack.types.channel_id,
      },
    },
    required: ["interactivity"],
  },
});

Usergroup ID

Declare a usergroup_id type:

// ...
attributes: {
    usergroup_id: {
      type: Schema.slack.types.usergroup_id,
    },
}
    // ...
Usergroup ID example

In this example datastore definition, we store work shift details for a team.

export const MyShifts = DefineDatastore("shifts", {
  primary_key: "id",
  attributes: {
    id: {
      type: Schema.types.string,
    },
    team_id: {
      type: Schema.types.string,
    },
    channel: {
      type: Schema.slack.types.channel_id,
    },
    usergroup_id: {
      type: Schema.slack.types.usergroup_id,
    },
    shiftRotation: {
      type: Schema.types.string,
    },
  },
});

Timestamp

Declare a timestamp type:

// ...
  inputs: {
    currentTime: {
      value: "{{data.trigger_ts}}",
      type: Schema.slack.types.timestamp,
    },
  }
  // ...
Timestamp example

In this example trigger, we call a workflow that logs an incident and the time it occurred.

const incidentTrigger: Trigger = {
  type: "shortcut",
  name: "Log an incident",
  workflow: "#/workflows/createIncidentByButtonClick",
  inputs: {
    currentTime: {
      value: "{{data.trigger_ts}}",
      type: Schema.slack.types.timestamp,
    },
    interactivity: {
      value: "{{data.interactivity}}",
    }
  }
}

Blocks

Declare a Block Kit JSON object type. You can use handmade Block Kit JSON objects, or those built with the Block Kit builder.

// ...
properties: {
      forecast: {
        type: Schema.slack.types.blocks,
      },
    },
// ...
Blocks example

In this example function, we get the current weather forecast.

export const ForecastFunctionDefinition = DefineFunction({
  callback_id: "get_forecast",
  title: "Weather forecast",
  description: "A function to get the weather forecast",
  source_file: "functions/weather_forecast.ts",
  input_parameters: {
    properties: {
      city: {
        type: Schema.types.string,
        description: "City",
      },
      country: {
        type: Schema.types.string,
        description: "Country",
      },
      state: {
        type: Schema.types.string,
        description: "State",
      },
    },
    required: ["city"],
  },
  output_parameters: {
    properties: {
      forecast: {
        type: Schema.slack.types.blocks,
        description: "Weather forecast",
      },
    },
    required: ["forecast"],
  },
});

Interactivity

Declare the interactivity type:

// ...
    properties: {
      interactivity: {
        type: Schema.slack.types.interactivity,
      },
    }
// ...
Interactivity example

In this example workflow, we specify that it is an interactive workflow.

const GreetingWorkflow = DefineWorkflow({
  callback_id: "greeting_workflow",
  title: "Send a greeting",
  description: "Send a greeting to channel",
  input_parameters: {
    properties: {
      interactivity: {
        type: Schema.slack.types.interactivity,
      },
      channel: {
        type: Schema.slack.types.channel_id,
      },
    },
    required: ["interactivity"],
  },
});

User context

Declare the user_context type:

// ...
  input_parameters: {
    properties: {
    person_reporting_bug: {
       type: Schema.slack.types.user_context,
       description: "Which user?",
      },
    }
  }
// ...
User context example

In this example workflow, we use the Schema.slack.types.user_context type to report a bug in a system and to collect the reporter's information.

  const ReportBugWorkflow = DefineWorkflow({
    callback_id: "report_bug",
    title: "Report a Bug",
    description: "Report a bug",
    input_parameters: {
      properties: {
        channel_id: {
          type: Schema.slack.types.channel_id,
          description: "Which channel?",
        },
      person_reporting_bug: {
        type: Schema.slack.types.user_context,
        description: "Which user?",
        },
      },
      required: ["person_reporting_bug"],
    },
  });

  ReportBugWorkflow.addStep(
    CreateBugFunction,
    {
      title: "title",
      summary: "summary",
      urgency: "S0",
      channel_id: ReportBugWorkflow.inputs.channel_id,
      creator: ReportBugWorkflow.inputs.person_reporting_bug,
    },
  );

Date

Declare a date type:

// ...
fields: {
  elements: [
    {
        name: "date",
        title: "Date Posted",
        type: Schema.slack.types.date,
      },
// ...
Date example

In this example workflow, a form requires a date as input, which is printed along with the message after the form is submitted.

const formData = TestReverseWorkflow.addStep(Schema.slack.functions.OpenForm, {
  title: "Reverse string form",
  submit_label: "Submit form",
  description: "Submit a string to reverse",
  interactivity: TestReverseWorkflow.inputs.interactivity,
  fields: {
    required: ["channel", "stringInput", "date"],
    elements: [
      {
        name: "stringInput",
        title: "String input",
        type: Schema.types.string,
      },
      {
        name: "date",
        title: "Date Posted",
        type: Schema.slack.types.date,
      },
      {
        name: "channel",
        title: "Post in",
        type: Schema.slack.types.channel_id,
        default: TestReverseWorkflow.inputs.channel,
      },
    ],
  },
});

// Add the date parameter as a step in your workflow. The message and date will be printed side by side.
TestReverseWorkflow.addStep(Schema.slack.functions.SendMessage, {
  channel_id: formData.outputs.fields.channel,
  message: reverseStep.outputs.reverseString + " " + formData.outputs.fields.date,
});

Rich text

Declare a rich_text type:

// ...
elements: [
      {
        name: "formattedStringInput",
        title: "String input",
        type: Schema.slack.types.rich_text, 
      },
]
// ...
Rich text example

In this example workflow, we collect a formatted message from the user using the rich_text type.

const formData = TestWorkflow.addStep(Schema.slack.functions.OpenForm, {
  title: "Send Message Form",
  submit_label: "Send Message form",
  interactivity: TestReverseWorkflow.inputs.interactivity,
  fields: {
    required: ["channel", "formattedStringInput"],
    elements: [
      {
        name: "formattedStringInput",
        title: "String input",
        type: Schema.slack.types.rich_text, 
      },
      {
        name: "channel",
        title: "Post in",
        type: Schema.slack.types.channel_id,
        default: TestReverseWorkflow.inputs.channel,
      },
    ],
  },
});

// To share this message object with other users, embed it into a built-in function such as SendMessage.
TestWorkflow.addStep(Schema.slack.functions.SendMessage, {
  channel_id: formData.outputs.fields.channel,
  message: formData.outputs.fields.formattedStringInput,
});