Skip to main content

blocks type

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

Type: slack#/types/blocks

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.

Declare an array of Block Kit JSON objects.

// ...
"input_parameters": {
"forecast": {
"type": "slack#/types/blocks"
}
}
// ...

If you use Block Kit builder to build your Block Kit objects, be sure to only grab the blocks array. For example:

[
{
"type": "section",
"text": {
"type": "plain_text",
"text": "This is a plain text section block.",
"emoji": true
}
},
{
"type": "image",
"image_url": "example.com/png"
"alt_text": "inspiration"
}
]
Blocks example

In this example function, we get the current weather forecast.

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

export const ForecastFunctionDefinition = DefineFunction({
callback_id: "get_forecast",
title: "Weather forecast",
description: "A function to get the weather forecast",
source_file: "functions/weather_forecast.ts",
input_parameters: {
properties: {
city: {
type: Schema.types.string,
description: "City",
},
country: {
type: Schema.types.string,
description: "Country",
},
state: {
type: Schema.types.string,
description: "State",
},
},
required: ["city"],
},
output_parameters: {
properties: {
forecast: {
type: Schema.slack.types.blocks,
description: "Weather forecast",
},
},
required: ["forecast"],
},
});