Skip to main content

object type

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

Type: object

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.
choicesEnumChoice[]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:

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

// ...
Object types are not supported within Workflow Builder at this time

If your function will be used within Workflow Builder, we suggest not using the object type at this time.

Objects can be typed or untyped. Here we have examples of both.

Typed Object

Refer to custom types for more information about typed objects, including properties and how to use DefineProperty to enforce required properties.

Declare a custom object type:

// ...
"input_parameters": {
"reviewer": {
"type": "object",
"properties": {
"login": { "type": "string" }
}
}
}

//...
Object example

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

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

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

Untyped Object

Untyped objects do not have properties defined on them. They are malleable; you can assign any kind of properties to them. In TypeScript lingo, these objects are typed as any.

Declare an untyped object type:

properties: {
flexibleObject: {
type: Schema.types.object,
}
},