How to trigger a Robocorp Cloud process from a Typeform submission
Typeform is a popular tool to create and manage online forms. In this article, we will see how you can trigger a process in Robocorp Cloud when a user submits a Typeform using Webhooks.
You will need:
- a Typeform account (this will work with a free account as well)
- a Robocorp Cloud account
- Robocorp Lab installed and connected to your Robocorp Cloud account
Get access to Typeform and create a form
Register or log in to your Typeform account and create a test form using the UI.
As an example, we have created a very simple form with three fields:
- an email field
- a text field
- a numeric field (opinion scale)
You can try the test form here.
Create a new process in Robocorp Cloud and enable the Process API for it
Access Robocorp Cloud, select your organization and workspace and create a new process under the
Workforce
tab. For this example, we decided to set up a new workspace calledtypeform
. In it we have created a process calledtypeform example process
:Enable the Process API access for your process and take note of the secret and the URL.
With the information from the Robocorp Cloud UI, we can create the webhook URL that we will use to trigger this process remotely via the API. The URL will look like this:
https://api.eu1.robocloud.eu/workspace-v1/workspaces/WORKSPACE_ID_HERE/processes/PROCESS_ID_HERE/runs
For the API to be able to trigger the process, we will also need to pass the secret to it. If the system we call the API from allows us to add custom headers to the API call, we should pass the secret as a header. If this is not possible (like in our case with Typeform), we can pass the secret as a query parameter instead.
So our final webhook URL will look like this:
https://api.eu1.robocloud.eu/workspace-v1/workspaces/WORKSPACE_ID_HERE/processes/PROCESS_ID_HERE/runs?robocloud-process-secret=SECRET_HERE
If available, the custom header method should always be preferred for security reasons. You can read more about this topic on the API documentation page.
Add the webhook to your form in Typeform
- In the Typeform admin UI, select the
Connect
button in the top bar. - Select the
Webhooks
button. - Add a new webhook and add the URL that you got in the previous step:
- Activate the webhook using the toggle button:
Add a new robot in your workspace in Robocorp Cloud
Your process needs to have at least one step associated with it to run.
While in your workspace in Robocorp Cloud, create a new robot. We decided to call it typeform
.
Create a new robot in Robocorp Lab
Our process is set up, but we have no robot added to it. Let's create one!
- Open Robocorp Lab and create a new robot:
- Open the
tasks.robot
file in editor mode by right-clicking on the file in the sidebar, and selectingOpen With
->Editor
, replace the existing content with this script and save the file:
*** Settings ***
Documentation A simple robot demonstrating how to get data from
... a typeform submission.
Library RPA.Robocloud.Items
*** Tasks ***
Get form submission data from Typeform and log it
${payload}= Get Work Item Payload
Log ${payload}
Robot code explained
- We are adding the
RPA.Robocloud.Items
library, that allows us to access the data coming from Typeform via the webhook. ${payload}= Get Work Item Payload
: Using theGet Work Item Payload
keyword, we access the payload data coming from Typeform.Log ${payload}
: For now, we will just print out the content of what we get from Typeform to the log.
Upload the robot to Robocorp Cloud
- Make sure that you have linked Robocorp Lab to your Robocorp Cloud account
- Click on the
Publish to Robocorp Cloud
button on the top right corner. - Select your workspace and your robot in the UI and click on the
Publish to Robocorp Cloud
button:
Add the robot step to the process in Robocorp Cloud
In Robocorp Cloud, select your process and add to it the robot you just uploaded:
Submit the Typeform and see the results in Robocorp Cloud
Submit your form in Typeform. This will cause the webhook to fire, and Robocorp Cloud will run your process!
When the process is complete, you can see the submitted values in the log:
You can also inspect the data that was passed to the process using the Robocorp Cloud UI:
Next steps
Now you know how to set up Typeform and Robocorp Cloud to run a robot when a form is submitted. Pretty neat!
You will probably want to do something with the data that you get from Typeform, so here are some pointers:
- Check the Typeform documentation about webhooks, and the Example webhooks payload in particular to get to know the schema of data that is sent over to Robocorp Cloud.
- Set up the
RPA.Robocloud.Items
library to work locally, so you can iterate on your robot code to extract the data and do whatever you need with it without having to trigger an actual form each time.