-
-
Notifications
You must be signed in to change notification settings - Fork 193
Dialog node
Guidone edited this page Dec 22, 2017
·
5 revisions
In Slack it's possible to trigger modal dialogs on the chat client.
Dialogs supports three field types: text
, textarea
and select
and can only be initiated by click on a button.
A dialog flow must implement 3 steps
- Add a
Open Dialog
button in aInline button node
orGeneric Template node
. Specify Modal id if there are several dialog forms - When a user clicks on a
Open Dialog
button, a message typedialog
is triggered from theSlack Receiver node
, the content of the payload is the Modal id specified in the button. At this point the chat flow should answer with aDialog node
which defines the modal fields. Use theSwitch node
to redirect incoming messages based on type. - When the user answers to a modal dialog, a message type
response
is triggered from theSlack Receiver node
, and contains the response hash (key is the name of the field, value is the answer). In order to extract the hash from theresponse
message use aParse node
using the Dialog response type. Use theSwitch node
to redirect theresponse
message to the properParse node
.
After the parse node the message.payload
will contain
{
my_text_field: 'test',
my_textarea_field: 'sadasda',
my_select_field: 'one'
}
Name | Type | Description |
---|---|---|
title | string | The title of the modal dialog. Required |
submitLabel | string | The label of the submit button |
messageId | string | The message id to modify, leave blank for a new message |
elements | array of elements | The elements of the modal form. Required |
The element
structure
Name | Type | Description |
---|---|---|
type | string | Type of element: text, textarea, select. Required |
label | string | The label form element. Required |
name | string | The name of the element, also used in hash result. Required |
value | string | The initial value of the element |
placeholder | string | Placeholder text of the form element |
hint | string | Little help below the form element |
optional | boolean | If the form element is optional, if not specified is mandatory |
subtype | string | Sub-type for text and textarea elements: email, number, tel, url |
minLength | number | Minimum length for text and textarea elements |
maxLength | number | Maximum length for text and textarea elements |
options | array of option | Options of the combo box for select elements |
The option
structure
Name | Type | Description |
---|---|---|
value | string | The value of the option. Required |
label | string | The label of the option. Required |
For example, in order to programmatically prepare the the modal form in a upstream Function node
:
msg.payload = {
title: 'My form',
submitLabel: 'OK',
elements: [
{
type: 'text',
name: 'my_text',
label: 'My Text'
},
{
type: 'select',
name: 'my_combo',
label: 'My Combo',
options: [
{ value: 'option_1', label: 'Option 1' },
{ value: 'option_2', label: 'Option 2' }
]
}
]
}