Skip to main content

string type

This reference documents the Slack types at the platform level. Their availability and structure may differ in each SDK

Type: string

PropertyTypeDescription
defaultThe type that is being described.An optional parameter default value.
descriptionstringAn optional parameter description.
examplesAn array of the type being described.An optional list of examples.
hintstringAn optional parameter hint.
titlestringAn optional parameter title.
typestringString that defines the parameter type.
minLengthnumberMinimum number of characters comprising the string.
maxLengthnumberMaximum number of characters comprising the string.
enumstring[]Constrain the available string options to just the list of strings denoted in the enum property. Usage of enum also instructs any UI that collects a value for this parameter to render a dropdown select input rather than a free-form text input.
choicesEnumChoice[]Defines labels that correspond to the enum values. See below.
formatstringDefine accepted format of the string. Valid options include url or email.

The choices property

The choices property is an array of EnumChoice objects. Here is a closer look at the properties of the EnumChoice object:

PropertyTypeDescription
defaultThe type that is being described. For example, the default for a boolean would be true or false.An optional parameter default value.
descriptionstringAn optional parameter description.
examplesAn array of the type being described.An optional list of examples.
hintstringAn optional parameter hint.
titlestringAn optional parameter title.
typestringString that defines the parameter type.
valueThe type that the EnumChoice object corresponds to; in the example below, it is stringThe value of the corresponding choice, which must map to the values present in the sibling enum property.
titlestringThe label to display for this EnumChoice.
descriptionstringAn optional description for this EnumChoice.
A choices example using the string Slack type,

In the following example for the string Slack type, defining the choices property allows us to have the label on the input form be capitalized, but the data we're going to save be lowercase.

import { DefineWorkflow, Schema } from "deno-slack-sdk/mod.ts";

// ...

const inputForm = LogFruitWorkflow.addStep(
Schema.slack.functions.OpenForm,
{
title: "Tell us your favorite fruit",
interactivity: LogFruitWorkflow.inputs.interactivity,
submit_label: "Submit",
fields: {
elements: [{
name: "Fruit",
title: "The three best fruits",
type: Schema.types.string,
enum: ['mango', 'strawberry', 'plum'],
choices: [
{value: 'mango', title: 'Mango!', description: 'Wonderfully tropical'},
{value: 'strawberry', title: 'Strawberry!', description: 'Absolutely fantastic'},
{value: 'plum', title: 'Plum!', description: 'Tart, just the way I like em'},
]
}]
required: ["Fruit"],
},
},
);

// ...

Declare a string type:

// ...
"notes": {
"type": "string",
"title": "notes"
}
// ...
String example

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

import { Schema } from "deno-slack-sdk/mod.ts";
import { CreateFTOWorkflow } from "../workflows/create_fto_workflow.ts";

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"],
},
},
);