Custom Steps for Workflow Builder (existing app)
If you don't have a paid workspace for development, you can join the Developer Program and provision a sandbox with access to all Slack features for free.
If you followed along with our create a custom step for Workflow Builder: new app tutorial, you have seen how to add custom steps to a brand new app. But what if you have an app up and running currently to which you'd like to add custom steps? You've come to the right place!
In this tutorial we will:
- Start with an existing Bolt app
- Add a custom workflow step in the app settings
- Wire up the new step to a function listener in our project, using the Bolt for Python framework
- See the step as a custom workflow step in Workflow Builder
Prerequisites
The custom steps feature is compatible with Bolt version 1.20.0 and above. First, update your package.json
file to reflect version 1.20.0 of Bolt, then run the following command in your terminal:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
In order to add custom workflow steps to an app, the app also needs to be org-ready. To do this, navigate to your app settings page and select your Bolt app.
Navigate to Org Level Apps in the left nav and click Opt-In, then confirm Yes, Opt-In.
Adding a new workflow step
Before we can add the new workflow step, we first need to ensure the workflow step is listening for the function_executed
event so that our app knows when the workflow step is executed.
Adding the function_executed
event subscription
Navigate to App Manifest in the left nav and add the function_executed
event subscription, then click Save Changes:
...
"settings": {
"event_subscriptions": {
"bot_events": [
...
"function_executed"
]
},
}
Adding the workflow step
Navigate to Workflow Steps in the left nav and click Add Step. This is where we'll configure our step's inputs, outputs, name, and description.
For illustration purposes in this tutorial, we're going to write a custom step called Request Time Off. When the step is invoked, a message will be sent to the provided manager with an option to approve or deny the time-off request. When the manager takes an action (approves or denies the request), a message is posted with the decision and the manager who made the decision. The step will take two user IDs as inputs, representing the requesting user and their manager, and it will output both of those user IDs as well as the decision made.
Add the pertinent details to the step:
Remember this callback_id
. We will use this later when implementing a function listener. Then add the input and output parameters:
Save your changes.