Skip to main content

date type

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

Type: slack#/types/date

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

// ...

Declare a date type:

// ...
"fields": {
"elements": [
{
"date_posted": {
"type": "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.

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

const TestReverseWorkflow = DefineWorkflow({
callback_id: "test_reverse",
title: "Test reverse",
input_parameters: {
properties: {
channel: { type: Schema.slack.types.channel_id },
interactivity: { type: Schema.slack.types.interactivity },
},
required: ["interactivity"],
},
});

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

import { ReverseFunction } from "../functions/reverse.ts";
const reverseStep = TestReverseWorkflow.addStep(ReverseFunction, {
input: formData.outputs.fields.stringInput,
});

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