# Passing External Data To Workflow Through Webhook

**URL:** <https://forums.losant.com/t/passing-external-data-to-workflow-through-webhook/2903>\
**Category:** Help\
**Tags:** webhook\
**Created:** [May 4, 2020, 6:54pm UTC](https://forums.losant.com/t/passing-external-data-to-workflow-through-webhook/2903 "2020-05-04T18:54:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebuka](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@ebuka](https://forums.losant.com/u/ebuka)\
**Post date:** [May 4, 2020, 6:54pm UTC](https://forums.losant.com/t/passing-external-data-to-workflow-through-webhook/2903/1 "2020-05-04T18:54:04Z")

</div>

Hello

I am having issues passing data through a webhook to my workflow. I have multi-field data that the workflow will need to use to operate such as 3 -4 parameters.

If this is achievable through the use of webhook, I will like to know the format for the https request.

Thank you

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 4, 2020, 7:29pm UTC](https://forums.losant.com/t/passing-external-data-to-workflow-through-webhook/2903/3 "2020-05-04T19:29:11Z")

</div>

Hey @ebuka,

I can type up a good example for you. However, I have two questions for you:

1. What issues are you having?
2. What are you doing with the webhook data? Reporting State, Creating an Event, etc.

---

<div class="post-metadata">

**Author:** ![ebuka](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@ebuka](https://forums.losant.com/u/ebuka)\
**Post date:** [May 4, 2020, 7:35pm UTC](https://forums.losant.com/t/passing-external-data-to-workflow-through-webhook/2903/4 "2020-05-04T19:35:51Z")

</div>

Hello @anaptfox

I will like to update an existing data table with new figures or thresholds for existing devices. I have my devices listed in a table along with some set points for which an event will be triggered.

An example is to pass a new temperature and humidity threshold value to the workflow, which will eventually update the corresponding row/column in a table.

---

<div class="post-metadata">

**Author:** ![ebuka](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@ebuka](https://forums.losant.com/u/ebuka)\
**Post date:** [May 5, 2020, 1:41pm UTC](https://forums.losant.com/t/passing-external-data-to-workflow-through-webhook/2903/5 "2020-05-05T13:41:02Z")

</div>

Hello @anaptrox

Please I was wondering if my response was clear enough and if you have had some time to look at this. I think an example will be sufficient.

Thank you

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 5, 2020, 1:41pm UTC](https://forums.losant.com/t/passing-external-data-to-workflow-through-webhook/2903/6 "2020-05-05T13:41:51Z")

</div>

Yes! Your explanation was great. I’m actually preparing your example right now.

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [May 5, 2020, 3:09pm UTC](https://forums.losant.com/t/passing-external-data-to-workflow-through-webhook/2903/7 "2020-05-05T15:09:54Z")

</div>

@ebuka,

Let’s say, for example, you had a Data Table that looked like this:

 ![Screen Shot 2020-05-05 at 9.45.34 AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/1/197688ec1fd38d1233064484f7cb5f4344982f2a.png)

Here, I’m going to walk through receiving a Webhook (that includes HTTP POST data) and using those values to update a Data Table with the same structure you see above.

Here is the data we can send to the Webhook:

{  
“deviceId”: “5eb16e1d1ac8cb000623fb1c”,  
“temperature\_threshold”: 94,  
“humidity\_threshold”: 60  
}

We can use [Postman](https://www.postman.com/) to make the request:

 ![postman-losant-webhook](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/6/6ce88402f04dc977edf6720def2554ed722591b2.png)

1. Configuring an HTTP Post request.
2. Losant Webhook.
3. Setting an `application/json` Content-Type.
4. This is the data we want to send to the Workflow.
5. Here is the response of the Webhook. You can have [Custom Replies](https://docs.losant.com/applications/webhooks/#custom-replies).

Here is the most simple workflow we can build:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/0/0283b2646127242163ab22c493d57922c3996c55.png)

1. Webhook Trigger
2. Table: Update Node
3. Debug Node

When the workflow triggers, it creates the following payload:

```auto
{
  ...
  "data": {
    "body": {
      "humidity_threshold": 60,
      "temperature_threshold": 94,
      "deviceId": "5eb16e1d1ac8cb000623fb1c"
    },
    "query": {},
    "headers": {
     ...
    },
    "method": "post",
    "path": "/"
  },
  "time": "2020-05-05T14:29:42.764Z"
}

```

All of the values are at `data.body` because they were in the body of the HTTP request.

Now that our values are on the payload, we can use them in our Table: Update Row Node.

 ![table-update-node](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/41c12dd915904d317e84aa48a9fa6ffeb9269699.png)

1. The Data Table to update
2. A [Data Table Query](https://docs.losant.com/data-tables/overview/#querying-table-data).
3. You can optionally insert if the row doesn’t exist.

Here we are using the following query: `deviceId === "{{data.body.deviceId}}"`.

This allows us to find the row in the Data Table where the “deviceId” column is equal to the current value at `{{data.body.deviceId}}`.

Then, we can use the other values to update the found row:

 ![Screen Shot 2020-05-05 at 10.59.09 AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/ce33e2e98fcd033d383656d4d0df83de57474b32.png)

Now, if you trigger what we have above, it will update the Data Table values when the Webhook is requested.

You can even take this workflow further by checking to see if the row existed and perform different actions based on the result:

 ![Screen Shot 2020-05-05 at 11.05.04 AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/e6e6b13d077dbe46068e1bb80e5c55b1a027a42b.png)

I’ve made the workflow above available for you to download [here](https://cdn2.hubspot.net/hubfs/742943/Education/Support/passing-external-data-to-workflow-through-webhook.flow).

---

<div class="post-metadata">

**Author:** ![ebuka](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@ebuka](https://forums.losant.com/u/ebuka)\
**Post date:** [May 5, 2020, 5:26pm UTC](https://forums.losant.com/t/passing-external-data-to-workflow-through-webhook/2903/9 "2020-05-05T17:26:43Z")

</div>

Thanks so much @anaptfox

I was able to get through with the guide you provided. Really appreciate your help with this.
