-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: document custom step usage #2198
Conversation
Co-authored-by: Fil Maj <[email protected]>
@@ -0,0 +1,101 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need help with the translation 🙏
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2198 +/- ##
=======================================
Coverage 81.59% 81.59%
=======================================
Files 19 19
Lines 1646 1646
Branches 464 464
=======================================
Hits 1343 1343
Misses 194 194
Partials 109 109 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
English bits look good to me, left one small comment. I've not tested with these instructs though, so I'll let someone else approve.
Removed the existing Reason for this is that it included information that was not bolt specific and duplicated in api.slack.com. It also seems like overkill to have a dedicated sidebar section for custom steps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job! Left some suggestions.
docs/content/basic/custom-steps.md
Outdated
<summary> | ||
Listening to custom step actions | ||
</summary> | ||
Your app can listen to user actions, like button clicks, created from `custom steps` using the `action` method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested tweak to the introduction here:
Your app can listen to user actions, like button clicks, created from `custom steps` using the `action` method. | |
Your app's custom steps may create interactivity points for users, for example: | |
- Post a message with a button | |
- [Open a modal view](creating-modals) | |
If such interaction points originate from a custom step execution, the events sent to your app representing the end-user interaction with these points are considered to be _function-scoped interactivity events_. These interactivity events can be handled by your app using the same concepts we covered earlier, such as [Listening to actions](action-listening) or [Listening to views](view-submissions). | |
The one addition that function-scoped interactivity events have is they will contain data related to the `function_executed` event they were spawned from, such as custom step input data and access to `complete()` and `fail()` handlers to manage step control flow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good 🙇 provides more information without duplicating documentation from api.slack.com
I had to adapt this slightly to because open modal views are not yet supported, but hopefully soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super solid! 🏆 🚀 I left a few comments on wording and a suggestion on introducing this ✨ as a concept ✨ but don't think those are blocking.
Removing ack
from the function
listener might be though! 😳 I'm finding this won't transpile when collected from the listener arguments...
I also agree with a lot of the suggestions from @filmaj and think this'll be good to merge once you think so!
docs/content/basic/custom-steps.md
Outdated
app.function('sample_custom_step', async ({ ack, inputs, complete, fail, logger }) => { | ||
try { | ||
await ack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app.function('sample_custom_step', async ({ ack, inputs, complete, fail, logger }) => { | |
try { | |
await ack(); | |
app.function('sample_custom_step', async ({ inputs, complete, fail, logger }) => { | |
try { |
Removing the ack
here since this isn't provided for function executions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep it in the docs, there are a number of issues opened related to calling ack before executing custom logic
Keeping this in hopes that it will help developers avoid a bug 🙏
We can remove it in a follow up PR as well 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/content/basic/custom-steps.md
Outdated
app.function('sample_function', async ({ ack, client, inputs, fail, logger }) => { | ||
try { | ||
await ack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app.function('sample_function', async ({ ack, client, inputs, fail, logger }) => { | |
try { | |
await ack(); | |
app.function('sample_function', async ({ client, inputs, fail, logger }) => { | |
try { |
slug: /concepts/custom-steps | ||
--- | ||
|
||
Your app can use the `function()` method to listen to incoming [custom step requests](https://api.slack.com/automation/functions/custom-bolt). 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://api.slack.com/concepts/manifests#functions) definition. Custom steps must be finalized using the `complete()` or `fail()` listener arguments to notify Slack that your app has processed the request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your app can use the `function()` method to listen to incoming [custom step requests](https://api.slack.com/automation/functions/custom-bolt). 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://api.slack.com/concepts/manifests#functions) definition. Custom steps must be finalized using the `complete()` or `fail()` listener arguments to notify Slack that your app has processed the request. | |
Your app can use the `function()` listener to listen to incoming [custom step requests](https://api.slack.com/automation/functions/custom-bolt). Custom steps are used in Workflow Builder to build workflows. | |
Adding a custom step starts with a definition in [the app manifest](https://api.slack.com/concepts/manifests#functions) and a `function()` listener listening for the `callback_id` of that function. Upon function execution the listener is called and can run whatever code, but must finish with either the `complete()` or `fail()` listener argument to end the step: |
Hoping to set a bit more context for custom steps in just the first paragraph! Also wanting to frame the following one as more instruction instead of reference, but feel free to change it or ignore 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not certain about the "method" vs "listener" naming!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the documentation uses the method
terminology instead of the listener
I think its better to be consistent and stick to method
We can send a follow up PR to update all the terms 👍
```json | ||
"functions": { | ||
"sample_function": { | ||
"title": "Sample function", | ||
"description": "Runs sample function", | ||
"input_parameters": { | ||
"user_id": { | ||
"type": "slack#/types/user_id", | ||
"title": "User", | ||
"description": "Message recipient", | ||
"is_required": true, | ||
"hint": "Select a user in the workspace", | ||
"name": "user_id" | ||
} | ||
}, | ||
"output_parameters": { | ||
"user_id": { | ||
"type": "slack#/types/user_id", | ||
"title": "User", | ||
"description": "User that completed the function", | ||
"is_required": true, | ||
"name": "user_id" | ||
} | ||
} | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it'd be nice to include this as <details>
in the docs so the inputs
and complete.outputs
in the examples have context, but not necessary 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then I'm not sure if that'd also mean referencing function_runtime
settings and the function_executed
event 😓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea 💯 done ✅
Co-authored-by: Fil Maj <[email protected]>
Co-authored-by: Fil Maj <[email protected]>
Co-authored-by: Fil Maj <[email protected]>
Co-authored-by: Eden Zimbelman <[email protected]>
…olt-js into document-custom-steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome saucesome! 😋 Thanks for addressing the feedback! 🚀
This PR aims to provide documentation for custom step usage in the bolt framework
Testing
cd ./docs
npm install
npm start
Requirements (place an
x
in each[ ]
)