array type
This reference documents the Slack types at the platform level. Their availability and structure may differ in each SDK
Type: array
| 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. |
items | object | The type of items in the array. Can be one of the following types: channel_id, user_id, usergroup_id, timestamp, string, integer, number, boolean, list_id, canvas_id, canvas_template_id, channel_canvas_id, team_id, file_id. |
minItems | integer | Minimum number of items allowed. |
maxItems | integer | Maximum number of items allowed. |
Declare an array of types:
- JSON Manifest
- Deno Slack SDK
// ...
"departments": {
"title": "Your department",
"type": "array",
"items": {
"type": "string",
"enum": [
"marketing", "design", "sales", "engineering"
]
}
}
// ...
// ...
{
name: "departments",
title: "Your department",
type: Schema.types.array,
items: {
type: Schema.types.string,
enum: ["marketing", "design", "sales", "engineering"],
},
default: ["sales", "engineering"],
}
// ...
Arrays and object types
Be sure to define the array's properties in the items object. Untyped objects are not currently supported. In addition, you can only use an object as the item type of array if it's a custom object. Otherwise, you may receive the following error:
Unexpected schema encountered for array type: failed to match exactly one allowed schema for items - {"type":"one_of"} (failed_constraint).
Array example
In this example function, we have an array of the custom type ChannelType as both an input_parameter and output_parameter. See this custom type and array in action in the Deno Archive Channel sample app.
const ChannelType = DefineType(...)
export const FilterStaleChannelsDefinition = DefineFunction({
callback_id: "filter_stale_channels",
title: "Filter Stale Channels",
description:
"Filter out any channels that have received messages within the last 6 months",
source_file: "functions/filter_stale_channels.ts",
input_parameters: {
properties: {
channels: {
type: Schema.types.array,
description: "The list of Channel IDs to filter",
items: {
type: ChannelType,
},
},
},
required: ["channels"],
},
output_parameters: {
properties: {
filtered_channels: {
type: Schema.types.array,
description: "The list of stale Channel IDs",
items: {
type: ChannelType,
},
},
},
required: [],
},
});