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
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.
12
+
13
+
```java
14
+
app.function("sample_function", (req, ctx) -> {
15
+
app.executorService().submit(() -> {
16
+
try {
17
+
var userId = req.getEvent().getInputs().get("user_id").asString();
18
+
var response = ctx.client().chatPostMessage(r -> r
19
+
.channel(userId) // sending a DM
20
+
.text("Hi! Thank you for submitting the request! We'll let you know once the processing completes.")
The corresponding app manifest function definition for the preceding function might look like this:
40
+
41
+
```json
42
+
"functions": {
43
+
"sample_function": {
44
+
"title": "Send a request",
45
+
"description": "Send some request to the backend",
46
+
"input_parameters": {
47
+
"user_id": {
48
+
"type": "slack#/types/user_id",
49
+
"title": "User",
50
+
"description": "Who to send it",
51
+
"is_required": true,
52
+
"hint": "Select a user in the workspace",
53
+
"name": "user_id"
54
+
}
55
+
},
56
+
"output_parameters": {
57
+
"channel_id": {
58
+
"type": "slack#/types/channel_id",
59
+
"title": "DM ID",
60
+
"description": "The DM ID",
61
+
"is_required": true,
62
+
"name": "channel_id"
63
+
},
64
+
"ts": {
65
+
"type": "string",
66
+
"title": "Message timestamp",
67
+
"description": "Sent message timestamp",
68
+
"is_required": true,
69
+
"name": "ts"
70
+
}
71
+
}
72
+
}
73
+
}
74
+
```
75
+
76
+
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 name of your app.
0 commit comments