How to post data to Built.io Flow via WebHook

Posting data to Built.io Flow via Webhook is quite easy. You can set parameters (key value pairs) through the Webhook URL directly. Alternatively, you can pass a large set of data in the body of the post call. This posted data can be accessed by using {{$request}} inside the actions.

Set parameters


Let’s say your Webhook URL is https://runflow.built.io/run/abc123 and you were trying to pass in the value apple under the parameter fruit. You can do so by running the following Webhook: https://runflow.built.io/run/abc123?fruit=apple. Now, if you want to use this value in any action, simply use {{$request.fruit}} in the given field.

Pass large data


Let us understand how to pass large data and use it in an action with the help of an example.

Add ‘Send an Email’ action to Built.io Flow canvas, and connect it to ‘Start’ and ‘Stop’ to create a workflow. Configure the ‘Send Email’ action, and fill up all the fields. In the ‘Body’ field, enter {{$request}}. This ensures that the data you pass in the Webhook URL will be fetched in the body of the email. Then, click on ‘Next’, test the action, and ‘Done’ to return to the canvas.

1.png

Now, configure the ‘Start’ icon. Select 'Webhook' from the list of trigger services that appear. Toggle webhook 'ON' and select either 'User Auth' or 'Auth Token' method to secure the webhook. Copy the webhook given in 'Webhook URL' field and click on 'Next', test the trigger, and click on 'Done'.

2.PNG

The given Webhook URL can be used with any REST API client (such as Postman) to post data. 

In Postman, select the HTTP request as ‘POST’, and enter the Webhook URL in the given field. Under headers, put ‘Content-Type’ as ‘application/json’. In the body field, select ‘raw’ and enter the data that you want to pass in JSON format. Once you are done with this, click on ‘Send’ located on the top right corner of the page.

pass-large-data-3-postman-image

As soon as you hit the ‘Send’ button, the workflow will run automatically. As a result, the recipient (specified in the ‘Send an Email’ action) will receive the passed data in email body (in JSON format).

pass-large-data-4-postman-image