number type
This reference documents the Slack types at the platform level. Their availability and structure may differ in each SDK
Type: number
| Property | Type | Description |
|---|---|---|
default | The type that is being described. | An optional parameter default value. |
description | string | An optional parameter description. |
examples | An array of the type being described. | An optional list of examples. |
hint | string | An optional parameter hint. |
title | string | An optional parameter title. |
type | string | String that defines the parameter type. |
minimum | number | Absolute minimum acceptable value for the number. |
maximum | number | Absolute maximum acceptable value for the number. |
enum | number[] | Constrain the available number options to just the list of numbers 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. |
choices | EnumChoice[] | Defines labels that correspond to the enum values. See below. |
The choices property
The choices property is an array of EnumChoice objects. Here is a closer look at the properties of the EnumChoice object:
| Property | Type | Description |
|---|---|---|
default | The type that is being described. For example, the default for a boolean would be true or false. | An optional parameter default value. |
description | string | An optional parameter description. |
examples | An array of the type being described. | An optional list of examples. |
hint | string | An optional parameter hint. |
title | string | An optional parameter title. |
type | string | String that defines the parameter type. |
value | The type that the EnumChoice object corresponds to; in the example below, it is string | The value of the corresponding choice, which must map to the values present in the sibling enum property. |
title | string | The label to display for this EnumChoice. |
description | string | An 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 number type:
- JSON manifest
- Deno Slack SDK
// ...
"distance": {
"title": "race distance",
"type": "number"
}
// ...
// ...
{
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.
import { Schema } from "deno-slack-sdk/mod.ts";
import { LogRunWorkflow } from "../workflows/log_run.ts";
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"],
},
},
);