Creating a workflow
Creating a slack hook from a contact form
Introduction
In this tutorial, we will create a workflow that will send a slack message when the webhook is called by a contact form. In the next tutorial we will then add the sending of an email to the workflow.
Workflows allow the chaining of api requests while keeping state. Here we will put to chain units into our chain. The first will take the inputs of the contact form and create a string. The second will post this string to a slack channel. This string can be then be modified via the CMS interface.
Add CMS entry
Create a new CMS entry (from the Product Factory menu). This will correspond to the message that you will receive on Slack. The text encapsulated by ${..} are variables that we will later map from our form to our slack message.
Add API request
We will now add an API request to map the parameters from the web form to the parameters in our slack message.
First create a new request (Low code menu). The /cms/substitute endpoint is a utility function provided by Digis that makes it easy to create custom strings during a workflow.
We can test it with the following request:
POST
https://workflow.digis.io/cms/substitute
Query Parameters
params
string
Dictionary where keys are the variables from the cms entry and values are the substitute values
uuid
string
The uuid of the cms entry
Create mappings
The next step is to define the mappings of the API request.
Add an input for each parameter (email, name, subject, message) using the following schema:
We then also need to add some extra inputs for authorisation and to specify the uuid to use.
For authorisation, you can use the following settings:
For the uuid, you need to take the uuid of the cms entry (copy it from the url) and create an input as follow:
Next we have to add an output:
We can test with the following request
POST
https://workflow.digis.io/request/exec
Path Parameters
params
string
{"uuid": "<uuid of request>"}
Query Parameters
data
string
Dictionary of variables and substitute values
Create a slack request
Create a new API request
Add the following inputs:
Make sure the text input then has name override set to msgOut
Create an API request chain
Next we have to add an api request chain to link the request together. Create a new chain (Name: Landing page - contact form).
Add a chain unit:
Add another chain unit
We can test with the following request:
POST
https://workflow.digis.io/request/chain/exec
Path Parameters
params
string
{"uuid": "<uuid of request chain>"}
Query Parameters
data
string
Dictionary of variables and substitute values
Using the workflow webhook
We can now use the workflow webhook from the cloud. Simply call it as described above. Here is an example body
Troubleshooting
You can test each of the individual steps of the chain as shown above in the examples.
N.B. currently the product service must be restarted to take into account changes in the workflows
Last updated
Was this helpful?