DataWeave Slack Library
Builders
slack::Builders
Provides functions to simplify the creation and composition of these Slack API features:
Index
Functions
Name | Description |
---|---|
actions | Generates an actions block. |
blocks | Generates the standard Block Kit syntax to define a group of blocks. |
button | Generates a button element with a simple plain text object and ID. |
buttonWithUrl | Generates a button element with a simple plain text object, an ID, and an URL. |
buttonWithValue | Generates a button element with a simple plain text object, an ID, and a value. |
context | Generates a context block with a single plain text element item. |
divider | Generates a divider block. |
externalSelect | Generates an external select element with a simple plain text object as placeholder and its ID. |
header | Generates a header block with a simple plain text object. |
image | Generates an image element with its URL and alternative text. |
inputBlock | Generates an input block with a simple text label. |
inputText | Generates an input object. |
mrkdwn | Generates a mrkdwn text object. |
multiStaticSelect | Generates a multi-static select element with a simple text placeholder, ID, and options. |
option | Generates an option object with a simple plain text object and its value. |
optionGroup | Generates an option group object with a simple plain text object and its options. |
radioButtons | Generates a radio buttons group, given its ID and options. |
section | Generates a simple section block with a mrkdwn object. |
staticSelect | Generates a static select element with a simple plain text object as placeholder, its ID, and options. |
staticSelectByGroups | Generates a static select element with a simple plain text object as placeholder, its ID, and option groups. |
text | Generates a plain text object with emojis enabled. |
withStyle | Adds a style field to a button. |
withUrl | Adds a URL field to a button. |
withValue | Adds a value field to a button. |
Functions
actions ↑↑
actions(actions: Array<Element>): Actions
Generates an actions block.
Parameters
Name | Type | Description |
---|---|---|
actions | Array<Element> | The array of interactive elements to render. |
Example
This examples generates an actions block with a simple button.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
actions([button("Click me!", "bait")])
Output
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Click me!",
"emoji": true
},
"action_id": "bait"
}
]
}
blocks ↑↑
blocks(blocks: Array<Block>)
Generates the standard Block Kit syntax to define a group of blocks.
Parameters
Name | Type | Description |
---|---|---|
blocks | Array<Block> | The array of blocks to render. |
Example
This example generates and uses a simple section as a block.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
blocks([section("Hello there!")])
Output
{
"blocks": [
{
"type": "section",
"text": {
"type": "plain_text",
"text": "Hello there!",
"emoji": true
}
}
]
}
button ↑↑
button(message: String, id: String): Button
Generates a button element with a simple plain text object and ID.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired text. |
id | String | The value to use in an action_id field. |
Example
This example generates a button with simple text and an ID called "bait".
Source
%dw 2.0
output application/json
import * from slack::Builders
---
button("Click me!", "bait")
Output
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Click me!",
"emoji": true
},
"action_id": "bait"
}
button(text: PlainText, id: String): Button
Generates a button element with a plain text object and ID.
Parameters
Name | Type | Description |
---|---|---|
text | PlainText | The plain text object to use. |
id | String | The value to use in an action_id field. |
Example
This example generates a button with text with an ID called "emoji".
Source
%dw 2.0
output application/json
import * from slack::Builders
---
button({'type': "plain_text", text: "Create your own :emoji:"}, "emoji")
Output
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Create your own :emoji:"
},
"action_id": "emoji"
}
buttonWithUrl ↑↑
buttonWithUrl(message: String, id: String, url: String): Button
Generates a button element with a simple plain text object, an ID, and an URL.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired text. |
id | String | The value to use in an action_id field. |
url | String | The URL to use. |
Example
This example generates a button with simple text, an ID called "bait", and a URL to the Slack site.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
buttonWithUrl("Click me!", "bait", "https://slack.com")
Output
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Click me!",
"emoji": true
},
"action_id": "bait",
"url": "https://slack.com"
}
buttonWithUrl(text: PlainText, id: String, url: String): Button
Generates a button element with a plain text object, an ID, and a URL.
Parameters
Name | Type | Description |
---|---|---|
text | PlainText | The plain text object to use. |
id | String | The value to use in an action_id field. |
url | String | The URL to use. |
Example
This example generates a button with an emoji and text, an ID called "emoji", and a URL to the Slack site.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
buttonWithUrl({'type': "plain_text", text: "Create your own :emoji:"}, "emoji", "https://slack.com")
Output
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Create your own :emoji:"
},
"action_id": "emoji",
"url": "https://slack.com"
}
buttonWithValue ↑↑
buttonWithValue(message: String, id: String, value: String): Button
Generates a button element with a simple plain text object, an ID, and a value.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired text. |
id | String | The value to use in an action_id field. |
value | String | The value to use. |
Example
This example generates a button with a simple text, an ID called "bait", and a value.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
buttonWithValue("Click me!", "bait", "something to share")
Output
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Click me!",
"emoji": true
},
"action_id": "bait",
"value": "something to share"
}
buttonWithValue(text: PlainText, id: String, value: String): Button
Generates a button element with a plain text object, an ID, and a value.
Parameters
Name | Type | Description |
---|---|---|
text | PlainText | The value to use in the desired text. |
id | String | The value to use in an action_id field. |
value | String | The value to use. |
Example
This example generates a button with text with an emoji, an ID called "emoji", and a value.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
buttonWithValue({'type': "plain_text", text: "Create your own :emoji:"}, "emoji", "origin")
Output
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Create your own :emoji:"
},
"action_id": "emoji",
"value": "origin"
}
context ↑↑
context(message: String): Context
Generates a context block with a single plain text element item.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use as text. |
Example
This example shows how context
behaves.
Source
%dw 2.0
output application/json
---
context(":calendar: Make sure to add this to your events")
Output
{
"type": "context",
"elements": [
{
"type": "plain_text",
"text": ":calendar: Make sure to add this to your events",
"emoji": true
}
]
}
context(elements: Array<Image | Text>): Context
Generates a context block with the desired elements.
Parameters
Name | Type | Description |
---|---|---|
elements | Array<Image|Text> | The image or text elements. |
Example
This example shows how context
behaves.
Source
%dw 2.0
output application/json
---
context([mrkdwn("Built with :heart: by the DataWeave team")])
Output
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Built with :heart: by the DataWeave team"
}
]
}
divider ↑↑
divider(): Divider
Generates a divider block.
Example
This example generates a divider block.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
divider()
Output
{
"type": "divider"
}
externalSelect ↑↑
externalSelect(placeholder: String, id: String): ExternalSelect
Generates an external select element with a simple plain text object as placeholder and its ID.
External Data Source Reference
Parameters
Name | Type | Description |
---|---|---|
placeholder | String | The value to use in the desired placeholder |
id | String | The value to use in an action_id field. |
Example
This example shows how externalSelect
behaves.
Source
%dw 2.0
output application/json
---
externalSelect("Choose a dish", "dishes")
Output
{
"type": "external_select",
"placeholder": {
"type": "plain_text",
"text": "Choose a dish",
"emoji": true
},
"action_id": "dishes"
}
externalSelect(placeholder: PlainText, id: String): ExternalSelect
Generates an external select element with a text object as placeholder and its ID.
External Data Source Reference
Parameters
Name | Type | Description |
---|---|---|
placeholder | PlainText | The text to use in the desired placeholder |
id | String | The value to use in an action_id field. |
Example
This example shows how externalSelect
behaves.
Source
%dw 2.0
output application/json
---
externalSelect(text("Choose a dish"), "dishes")
Output
{
"type": "external_select",
"placeholder": {
"type": "plain_text",
"text": "Choose a dish",
"emoji": true
},
"action_id": "dishes"
}
header ↑↑
header(message: String): Header
Generates a header block with a simple plain text object.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired text. |
Example
This example generates a header with a simple text.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
header("Hello!")
Output
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Hello!",
"emoji": true
}
}
header(text: PlainText): Header
Generates a header block with a plain text object.
Parameters
Name | Type | Description |
---|---|---|
text | PlainText | The plain text object to use. |
Example
This example generates a header with a plain text object with no support for emojis.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
header({
'type': "plain_text",
text: "Hello!",
emojis: false
})
Output
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Hello!",
"emoji": false
}
}
image ↑↑
image(url: String, text: String): Image
Generates an image element with its URL and alternative text.
Parameters
Name | Type | Description |
---|---|---|
url | String | The URL to the image. |
text | String | The text to use if the image cannot be rendered. |
Example
This example shows how image
behaves.
Source
%dw 2.0
output application/json
---
image("https://api.slack.com/img/blocks/bkb_template_images/profile_1.png", "Michael Scott")
Output
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_1.png",
"alt_text": "Michael Scott"
}
image(url: String, altText: String, title: String): ImageBlock
Generates an image block with a simple text title.
Parameters
Name | Type | Description |
---|---|---|
url | String | The URL for the image. |
altText | String | The alternative text for the image. |
title | String | The value to use for the text title. |
Example
This example shows how image
behaves.
Source
%dw 2.0
output application/json
---
image("https://api.slack.com/img/blocks/bkb_template_images/profile_1.png", "profile pic", "Your new profile picture is saved")
Output
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_1.png",
"alt_text": "profile pic",
"title": {
"type": "plain_text",
"text": "Your new profile picture is saved",
"emoji": true
}
}
image(url: String, altText: String, title: PlainText): ImageBlock
Generates an image block with a text title.
Parameters
Name | Type | Description |
---|---|---|
url | String | The URL for the image. |
altText | String | The alternative text for the image. |
title | PlainText | The text value to use as the title. |
Example
This example shows how image
behaves.
Source
%dw 2.0
output application/json
---
image("https://api.slack.com/img/blocks/bkb_template_images/profile_1.png", "profile pic", text("Your new profile picture is saved"))
Output
{
"type": "image",
"image_url": "https://api.slack.com/img/blocks/bkb_template_images/profile_1.png",
"alt_text": "profile pic",
"title": {
"type": "plain_text",
"text": "Your new profile picture is saved",
"emoji": true
}
}
inputBlock ↑↑
inputBlock(label: String, element: Element): Input
Generates an input block with a simple text label.
Parameters
Name | Type | Description |
---|---|---|
label | String | The label for the input. |
element | Element | The element to use in the input. |
Example
This example shows how inputBlock
behaves.
Source
%dw 2.0
output application/json
---
inputBlock("Please select your desired lunch:", inputText("lunch"))
Output
{
"type": "input",
"label": {
"type": "plain_text",
"text": "Please select your desired lunch:",
"emoji": true
},
"element": {
"type": "plain_text_input",
"action_id": "lunch",
"multiline": false
}
}
inputBlock(label: PlainText, element: Element): Input
Generates an input block.
Parameters
Name | Type | Description |
---|---|---|
label | PlainText | The label for the input. |
element | Element | The element to use in the input. |
Example
This example shows how inputBlock
behaves.
Source
%dw 2.0
output application/json
---
inputBlock(text("Please select your desired lunch:"), inputText("lunch"))
Output
{
"type": "input",
"label": {
"type": "plain_text",
"text": "Please select your desired lunch:",
"emoji": true
},
"element": {
"type": "plain_text_input",
"action_id": "lunch",
"multiline": false
}
}
inputText ↑↑
inputText(id: String, multiline: Boolean = false): PlainTextInput
Generates an input object.
Plain-text Input Element Reference
Parameters
Name | Type | Description |
---|---|---|
id | String | The value to use in the action_id field. |
multiline | Boolean | Whether the input should be multiline. Defaults to false . |
Example
This example shows how inputText
behaves.
Source
%dw 2.0
output application/json
---
inputText("suggestions", true)
Output
{
"type": "plain_text_input",
"action_id": "suggestions",
"multiline": true
}
mrkdwn ↑↑
mrkdwn(message: String): Mrkdwn
Generates a mrkdwn text object.
Parameters
Name | Type | Description |
---|---|---|
message | String | The mrkdwn to use. |
Example
This example generates a mrkdwn text object that has bold text.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
mrkdwn("*Hello*")
Output
{
"type": "mrkdwn",
"text": "*Hello*"
}
multiStaticSelect ↑↑
multiStaticSelect(placeholder: String, id: String, options: Array<Option>): MultiStaticSelect
Generates a multi-static select element with a simple text placeholder, ID, and options.
Multi-select Menu Element Reference
Parameters
Name | Type | Description |
---|---|---|
placeholder | String | The value to use in the desired placeholder. |
id | String | The value to use in the action_id field. |
options | Array<Option> | The options to select. |
Example
This example shows how multiStaticSelect
behaves.
Source
%dw 2.0
output application/json
var versions = ["4.2.1", "4.2.2", "4.3.0"]
---
multiStaticSelect("Choose versions...", "versions", versions map ((item, index) -> option(item, item)))
Output
{
"type": "multi_static_select",
"placeholder": {
"type": "plain_text",
"text": "Choose versions...",
"emoji": true
},
"action_id": "versions",
"options": [
{
"text": {
"type": "plain_text",
"text": "4.2.1",
"emoji": true
},
"value": "4.2.1"
},
{
"text": {
"type": "plain_text",
"text": "4.2.2",
"emoji": true
},
"value": "4.2.2"
},
{
"text": {
"type": "plain_text",
"text": "4.3.0",
"emoji": true
},
"value": "4.3.0"
}
]
}
multiStaticSelect(placeholder: PlainText, id: String, options: Array<Option>): MultiStaticSelect
Generates a multi-static select element with its placeholder, ID, and options.
Multi-select Menu Element Reference
Parameters
Name | Type | Description |
---|---|---|
placeholder | PlainText | The text to use as a placeholder. |
id | String | The value to use in the action_id field. |
options | Array<Option> | The options to select. |
Example
This example shows how multiStaticSelect
behaves.
Source
%dw 2.0
output application/json
var versions = ["4.2.1", "4.2.2", "4.3.0"]
---
multiStaticSelect(text("Choose versions..."), "versions", versions map ((item, index) -> option(item, item)))
Output
{
"type": "multi_static_select",
"placeholder": {
"type": "plain_text",
"text": "Choose versions...",
"emoji": true
},
"action_id": "versions",
"options": [
{
"text": {
"type": "plain_text",
"text": "4.2.1",
"emoji": true
},
"value": "4.2.1"
},
{
"text": {
"type": "plain_text",
"text": "4.2.2",
"emoji": true
},
"value": "4.2.2"
},
{
"text": {
"type": "plain_text",
"text": "4.3.0",
"emoji": true
},
"value": "4.3.0"
}
]
}
option ↑↑
option(message: String, value: String)
Generates an option object with a simple plain text
object and its value.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired text. |
value | String | The value to use in the option. |
Example
This example generates multiple options from a list of strings, using the same text and value.
Source
%dw 2.0
output application/json
import * from slack::Builders
var versions = ["4.3.0", "4.2.2", "4.1.6"]
---
versions map ((item) -> option(item, item))
Output
[
{
"text": {
"type": "plain_text",
"text": "4.3.0",
"emoji": true
},
"value": "4.3.0"
},
{
"text": {
"type": "plain_text",
"text": "4.2.2",
"emoji": true
},
"value": "4.2.2"
},
{
"text": {
"type": "plain_text",
"text": "4.1.6",
"emoji": true
},
"value": "4.1.6"
}
]
option(text: Text, val: String): Option
Generates an option object with a text object and its value.
Parameters
Name | Type | Description |
---|---|---|
text | Text | The text to use. |
value | String | The value to use in the option. |
Example
This example generates an option with mrkdwn text to select the color red. Its value references the hex
color representation for red.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
option(mrkdwn("*Red*"), "FF0000")
Output
{
"text": {
"type": "mrkdwn",
"text": "*Red*"
},
"value": "FF0000"
}
optionGroup ↑↑
optionGroup(message: String, options: Array<Option>): OptionGroup
Generates an option group object with a simple plain text object and its options.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired text. |
options | Array<Option> | The options to group. |
Example
This example generates an option group with a simple value for some options.
Source
%dw 2.0
output application/json
import * from slack::Builders
var options = ["4.3.0", "4.2.2"] map ((item) -> option(item, item))
---
optionGroup("Recommended", options)
Output
{
"label": {
"type": "plain_text",
"text": "Recommended",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "4.3.0",
"emoji": true
},
"value": "4.3.0"
},
{
"text": {
"type": "plain_text",
"text": "4.2.2",
"emoji": true
},
"value": "4.2.2"
}
]
}
optionGroup(text: PlainText, options: Array<Option>): OptionGroup
Generates an option group object with a plain text object and its options.
Parameters
Name | Type | Description |
---|---|---|
text | PlainText | The plain text to use. |
options | Array<Option> | The options to group. |
Example
This example generates an option group with text for some options.
Source
%dw 2.0
output application/json
import * from slack::Builders
var options = ["4.2.0", "4.2.1"] map ((item) -> option(item, item))
---
optionGroup({'type': "plain_text", text: "Others"}, options)
Output
{
"label": {
"type": "plain_text",
"text": "Others"
},
"options": [
{
"text": {
"type": "plain_text",
"text": "4.2.0",
"emoji": true
},
"value": "4.2.0"
},
{
"text": {
"type": "plain_text",
"text": "4.2.1",
"emoji": true
},
"value": "4.2.1"
}
]
}
radioButtons ↑↑
radioButtons(id: String, options: Array<Option>): RadioButtonGroup
Generates a radio buttons group, given its ID and options.
Radio Button Group Element Reference
Parameters
Name | Type | Description |
---|---|---|
id | String | The value to use in the action_id field. |
options | Array<Option> | The options to group. |
Example
This example shows how radioButtons
behaves.
Source
%dw 2.0
output application/json
---
radioButtons("food", ["spaghetti", "fusilli", "orecchiette"] map option($, $))
Output
{
"type": "radio_buttons",
"action_id": "food",
"options": [
{
"text": {
"type": "plain_text",
"text": "spaghetti",
"emoji": true
},
"value": "spaghetti"
},
{
"text": {
"type": "plain_text",
"text": "fusilli",
"emoji": true
},
"value": "fusilli"
},
{
"text": {
"type": "plain_text",
"text": "orecchiette",
"emoji": true
},
"value": "orecchiette"
}
]
}
section ↑↑
section(message: String): Section
Generates a simple section block with a mrkdwn object.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired mrkdwn text. |
Example
This example generates a section with mrkdwn text.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
section("Hello!")
Output
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello!"
}
}
section(text: Text): Section
Generates a section block with a text object.
Parameters
Name | Type | Description |
---|---|---|
text | Text | The text object to use. |
Example
This example generates a section with mrkdwn text.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
section(mrkdwn("*Hello*"))
Output
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Hello*"
}
}
section(message: String, accessory: Element): Section
Generates a section block with a mrkdwn text object and an accessory element.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired mrkdwn text. |
accessory | Element | The element to use. |
Example
This example generates a section with simple text and a simple button.
Source
%dw 2.0
output application/json
---
section("*Tim's Farewell Party* is tonight at 8 PM", button("RSVP", "invite"))
Output
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Tim's Farewell Party* is tonight at 8 PM"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "RSVP",
"emoji": true
},
"action_id": "invite"
}
}
section(text: Text, accessory: Element): Section
Generates a section block with a text object and an accessory element.
Parameters
Name | Type | Description |
---|---|---|
text | Text | The text object to use. |
accessory | Element | The element to use. |
Example
This example generates a section with mrkdwn text and a simple button.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
section(mrkdwn("*Hello*"), button("Click me!", "bait"))
Output
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Hello*"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click me!",
"emoji": true
},
"action_id": "bait"
}
}
section(fields: Array<Text>): Section
Generates a section block with an array of text objects or fields.
Parameters
Name | Type | Description |
---|---|---|
fields | Array<Text> | An array of text objects to use. |
Example
This example generates a section with mrkdwn text and plain text.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
section([mrkdwn("*Hello*"), text("Bye!")])
Output
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Hello*"
},
{
"type": "plain_text",
"text": "Bye!",
"emoji": true
}
]
}
section(fields: Array<Text>, accessory: Element): Section
Generates a section block with an array of text objects or fields, and an accessory element.
Parameters
Name | Type | Description |
---|---|---|
fields | Array<Text> | An array of text objects to use. |
accessory | Element | The element to use. |
Example
This example generates a section with mrkdwn text, plain text, and a simple button.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
section([mrkdwn("*Hello*"), text("Bye!")], button("Click me!", "bait"))
Output
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Hello*"
},
{
"type": "plain_text",
"text": "Bye!",
"emoji": true
}
],
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click me!",
"emoji": true
},
"action_id": "bait"
}
}
staticSelect ↑↑
staticSelect(placeholder: String, id: String, options: Array<Option>): StaticSelect
Generates a static select element with a simple plain text object as placeholder, its ID, and options.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired placeholder. |
id | String | The value to use in an action_id field. |
options | Array<Option> | The array of options to offer. |
Example
This example creates a static group of options with a simple text placeholder.
Source
%dw 2.0
output application/json
import * from slack::Builders
var options = ["4.3.0", "4.2.2", "4.1.6"] map ((item) -> option(item, item))
---
staticSelect("Choose a version...", "version_menu", options)
Output
{
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Choose a version...",
"emoji": true
},
"action_id": "version_menu",
"options": [
{
"text": {
"type": "plain_text",
"text": "4.3.0",
"emoji": true
},
"value": "4.3.0"
},
{
"text": {
"type": "plain_text",
"text": "4.2.2",
"emoji": true
},
"value": "4.2.2"
},
{
"text": {
"type": "plain_text",
"text": "4.1.6",
"emoji": true
},
"value": "4.1.6"
}
]
}
staticSelect(placeholder: PlainText, id: String, options: Array<Option>): StaticSelect
Generates an static select element with a simple plain text object as placeholder, its ID, and options.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired placeholder. |
id | String | The value to use in an action_id field. |
options | Array<Option> | The array of options to offer. |
Example
This example creates a static group of options with a simple text placeholder.
Source
%dw 2.0
output application/json
import * from slack::Builders
var options = ["4.3.0", "4.2.2", "4.1.6"] map ((item) -> option(item, item))
---
staticSelect("Choose a version...", "version_menu", options)
Output
{
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Choose a version...",
"emoji": true
},
"action_id": "version_menu",
"options": [
{
"text": {
"type": "plain_text",
"text": "4.3.0",
"emoji": true
},
"value": "4.3.0"
},
{
"text": {
"type": "plain_text",
"text": "4.2.2",
"emoji": true
},
"value": "4.2.2"
},
{
"text": {
"type": "plain_text",
"text": "4.1.6",
"emoji": true
},
"value": "4.1.6"
}
]
}
staticSelectByGroups ↑↑
staticSelectByGroups(placeholder: String, id: String, optionGroups: Array<OptionGroup>): StaticSelect
Generates a static select element with a simple plain text object as placeholder, its ID, and option groups.
Parameters
Name | Type | Description |
---|---|---|
message | String | The value to use in the desired placeholder. |
id | String | The value to use in an action_id field. |
optionGroups | Array<OptionGroup> | The array of options groups to offer. |
Example
This example creates a static group of option groups with a simple text placeholder.
Source
%dw 2.0
output application/json
import * from slack::Builders
var recommendedGroup = optionGroup("Recommended", [option("4.3.0", "latest")])
var otherGroup = optionGroup("Other", [option("4.1.1", "original")])
---
staticSelectGrouped("Choose a version...", "version_menu", [recommendedGroup, otherGroup])
Output
{
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Choose a version...",
"emoji": true
},
"action_id": "version_menu",
"option_groups": [
{
"label": {
"type": "plain_text",
"text": "Recommended",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "4.3.0",
"emoji": true
},
"value": "latest"
}
]
},
{
"label": {
"type": "plain_text",
"text": "Others",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "4.1.1",
"emoji": true
},
"value": "original"
}
]
}
]
}
staticSelectByGroups(placeholder: PlainText, id: String, optionGroups: Array<OptionGroup>): StaticSelect
Generates an static select element with a plain text object as placeholder, its ID, and option groups.
Parameters
Name | Type | Description |
---|---|---|
text | PlainText | The text to use as a placeholder. |
id | String | The value to use in an action_id field. |
optionGroups | Array<OptionGroup> | The array of options groups to offer. |
Example
This example creates a static group of option groups with a text placeholder.
Source
%dw 2.0
output application/json
import * from slack::Builders
var recommendedGroup = optionGroup("Recommended", [option("4.3.0", "latest")])
var otherGroup = optionGroup("Other", [option("4.1.1", "original")])
---
staticSelectByGroups({'type': "plain_text", text:"Some versions"}, "version_menu", [recommendedGroup, otherGroup])
Output
{
"type": "static_select",
"placeholder": {
"type": "plain_text",
"text": "Some versions"
},
"action_id": "version_menu",
"option_groups": [
{
"label": {
"type": "plain_text",
"text": "Recommended",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "4.3.0",
"emoji": true
},
"value": "latest"
}
]
},
{
"label": {
"type": "plain_text",
"text": "Others",
"emoji": true
},
"options": [
{
"text": {
"type": "plain_text",
"text": "4.1.1",
"emoji": true
},
"value": "original"
}
]
}
]
}
text ↑↑
text(message: String): PlainText
Generates a plain text object with emojis enabled.
Parameters
Name | Type | Description |
---|---|---|
message | String | The text to use. |
Example
This example generates a text object that has a wave emoji.
Source
%dw 2.0
output application/json
import * from slack::Builders
---
text("Hello! :wave:")
Output
{
"type": "plain_text",
"text": "Hello! :wave:",
"emoji": true
}
withStyle ↑↑
withStyle(button: Button, style: Style): Button
Adds a style field to a button.
Parameters
Name | Type | Description |
---|---|---|
button | Button | The button to add a value to. |
style | Style | The style to add. |
Example
This example shows how to use withStyle
.
Source
%dw 2.0
output application/json
---
button("Click me!", "bait") withStyle "danger"
Output
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Click me!",
"emoji": true
},
"action_id": "bait",
"style": "danger"
}
withUrl ↑↑
withUrl(button: Button, url: String): Button
Adds a URL field to a button.
Parameters
Name | Type | Description |
---|---|---|
button | Button | The button to add a value to. |
url | String | The URL to add. |
Example
This example shows how to use withUrl
.
Source
%dw 2.0
output application/json
---
button("Click me!", "bait") withUrl "http://httpbin.org"
Output
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Click me!",
"emoji": true
},
"action_id": "bait",
"url": "http://httpbin.org"
}
withValue ↑↑
withValue(button: Button, value: String): Button
Adds a value field to a button.
Parameters
Name | Type | Description |
---|---|---|
button | Button | The button to add a value to. |
value | String | The value to add. |
Example
This example shows how to use withValue
.
Source
%dw 2.0
output application/json
---
button("Click me!", "bait") withValue "spam"
Output
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Click me!",
"emoji": true
},
"action_id": "bait",
"value": "spam"
}