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
| 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. |
Declare an array of Block Kit JSON objects.
- JSON manifest
- Deno Slack SDK
// ...
"input_parameters": {
"forecast": {
"type": "slack#/types/blocks"
}
}
// ...
// ...
properties: {
forecast: {
type: Schema.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"],
},
});