You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/guides/bolt-basics.md
+10-9
Original file line number
Diff line number
Diff line change
@@ -31,19 +31,20 @@ Here is the list of the available methods to dispatch events.
31
31
32
32
|Method|Constraints (value: type)|Description|
33
33
|-|-|-|
34
-
|`app.event`|event type: `Class\<Event\>`|[Events API](/guides/events-api): Responds to any kinds of bot/user events you subscribe.|
35
-
|`app.message`|keyword: `String`\|`Pattern`|[Events API](/guides/events-api): Responds to messages posted by a user only when the text in messages matches the given keyword or regular expressions.|
36
-
|`app.command`|command name: `String`\|`Pattern`|[Slash Commands](/guides/slash-commands): Responds to slash command invocations in the workspace.|
34
+
|`app.attachmentAction`|callback_id: `String`\|`Pattern`|Legacy Messaging: Responds to user actions in attachments. These events can be triggered in only messages.|
37
35
|`app.blockAction`|action_id: `String`\|`Pattern`|[Interactive Components](/guides/interactive-components): Responds to user actions (e.g., click a button, choose an item from select menus, radio buttons, etc.) in `blocks`. These events can be triggered in all the surfaces (messages, modals, and Home tabs).|
38
36
|`app.blockSuggestion`|action_id: `String`\|`Pattern`|[Interactive Components](/guides/interactive-components): Responds to user actions to input a keyword (the length needs to be the `min_query_length` or longer) in select menus (external data source).|
39
-
|`app.viewSubmission`|callback_id: `String`\|`Pattern`|[Modals](/guides/modals): Responds to data submissions in modals.|
40
-
|`app.viewClosed`|callback_id: `String`\|`Pattern`|[Modals](/guides/modals): Responds to the events where users close modals by clicking Cancel buttons. The `notify_on_close` has to be `true` when opening/pushing the modal.|
41
-
|`app.globalShortcut`|callback_id: `String`\|`Pattern`|[Shortcuts](/guides/shortcuts): Responds to global shortcut invocations.|
42
-
|`app.messageShortcut`|callback_id: `String`\|`Pattern`|[Shortcuts](/guides/shortcuts): Responds to shortcut invocations in message menus.|
37
+
|`app.command`|command name: `String`\|`Pattern`|[Slash Commands](/guides/slash-commands): Responds to slash command invocations in the workspace.|
38
+
|`app.dialogCancellation`|callback_id `String`\|`Pattern`|Dialogs: Responds to the events where users close dialogs by clicking Cancel buttons.|
43
39
|`app.dialogSubmission`|callback_id: `String`\|`Pattern`|Dialogs: Responds to data submissions in dialogs.|
44
40
|`app.dialogSuggestion`|callback_id: `String`\|`Pattern`|Dialogs: Responds to requests to load options for `"external"` typed select menus in dialogs.|
45
-
|`app.dialogCancellation`|callback_id `String`\|`Pattern`|Dialogs: Responds to the events where users close dialogs by clicking Cancel buttons.|
46
-
|`app.attachmentAction`|callback_id: `String`\|`Pattern`|Legacy Messaging: Responds to user actions in attachments. These events can be triggered in only messages.|
41
+
|`app.event`|event type: `Class\<Event\>`|[Events API](/guides/events-api): Responds to any kinds of bot/user events you subscribe.|
42
+
| `app.function` | callback_id: `String`\|`Pattern` | [Custom steps](/guides/custom-steps): Defines a function that can be used as a custom step in [Workflow Builder](https://slack.com/help/articles/360035692513-Guide-to-Slack-Workflow-Builder).
43
+
|`app.globalShortcut`|callback_id: `String`\|`Pattern`|[Shortcuts](/guides/shortcuts): Responds to global shortcut invocations.|
44
+
|`app.message`|keyword: `String`\|`Pattern`|[Events API](/guides/events-api): Responds to messages posted by a user only when the text in messages matches the given keyword or regular expressions.|
45
+
|`app.messageShortcut`|callback_id: `String`\|`Pattern`|[Shortcuts](/guides/shortcuts): Responds to shortcut invocations in message menus.|
46
+
|`app.viewClosed`|callback_id: `String`\|`Pattern`|[Modals](/guides/modals): Responds to the events where users close modals by clicking Cancel buttons. The `notify_on_close` has to be `true` when opening/pushing the modal.|
47
+
|`app.viewSubmission`|callback_id: `String`\|`Pattern`|[Modals](/guides/modals): Responds to data submissions in modals.|
Your app can use the `function()` method to listen to incoming [custom step requests](https://docs.slack.dev/workflows/workflow-steps). Custom steps are used in Workflow Builder to build workflows. The method requires a step `callback_id` of type `string`. This `callback_id` must also be defined in your [Function](https://docs.slack.dev/reference/app-manifest#functions) definition. Custom steps must be finalized using the `complete()` or `fail()` listener arguments to notify Slack that your app has processed the request.
7
+
8
+
*`complete()` requires one argument: an `outputs` object. It ends your custom step successfully and provides an object containing the outputs of your custom step as per its definition.
9
+
*`fail()` requires one argument: `error` of type `string`. It ends your custom step unsuccessfully and provides a message containing information regarding why your custom step failed.
10
+
11
+
You can reference your custom step's inputs using the `getInputs()` method shown below.
The corresponding function definition section of the app manifest for the preceding function might look like this:
40
+
41
+
```json
42
+
...
43
+
"functions": {
44
+
"sample_function": {
45
+
"title": "Send a request",
46
+
"description": "Send some request to the backend",
47
+
"input_parameters": {
48
+
"user_id": {
49
+
"type": "slack#/types/user_id",
50
+
"title": "User",
51
+
"description": "Who to send it",
52
+
"is_required": true,
53
+
"hint": "Select a user in the workspace",
54
+
"name": "user_id"
55
+
}
56
+
},
57
+
"output_parameters": {
58
+
"channel_id": {
59
+
"type": "slack#/types/channel_id",
60
+
"title": "DM ID",
61
+
"description": "The DM ID",
62
+
"is_required": true,
63
+
"name": "channel_id"
64
+
},
65
+
"ts": {
66
+
"type": "string",
67
+
"title": "Message timestamp",
68
+
"description": "Sent message timestamp",
69
+
"is_required": true,
70
+
"name": "ts"
71
+
}
72
+
}
73
+
}
74
+
}
75
+
```
76
+
77
+
Once your custom step is defined in your app's manifest and implemented in code, it is discoverable in Workflow Builder when you **Add Step** and search for the title of your step or name of your app.
0 commit comments