Capture webhook data and enter in variable


#1

1) Give a description of the problem
I am unable capture the webhook data from parsio parser for my daily water usage.

2) What is the expected behaviour?
have the gallons used populate a variable

3) What is happening/not happening?
I am able to trigger the ifttt from the webhook but I am struggling on how to capture the info in webcore.

Here’s what the parsed json data is:
{

“meter”: “90248704”,

“gallons”: “38”,

}

**4) Post a Green Snapshot of the piston!

5) Attach logs after turning logging level to Full
11/12/2021, 1:48:03 PM +995ms
+0ms ╔Starting piston… (v0.3.110.20191009)
+1113ms ║╔Subscribing to devices…
+1143ms ║║Subscribing to Home.ifttt.gallons…
+1444ms ║╚Finished subscribing (351ms)
+1476ms ║Comparison (string) null executes (string) gallons = false (2ms)
+1478ms ║Cancelling condition #2’s schedules…
+1479ms ║Cancelling condition #1’s schedules…
+1493ms ╚Piston successfully started (1493ms)


#2

Are you able to call the URL directly from a browser or is ifttt a requirement?


#3

I’ve not used a call ot iftt, however when calling a url the result comes back in the variable $response, it may be worth checking that after the call


#4

I think I can just populate the values using the piston url in the parsio webhook address, I’m just not sure how to capture that info in webcore.


#5

I am using the piston external URL in this edited piston to try to capture the number of gallons but I just get a value of “null”.

Log:
11/13/2021, 8:53:02 AM +350ms
+1ms ╔Received event [Home].execute = 161.35.74.221 with a delay of 122ms
+45ms ║RunTime Analysis CS > 19ms > PS > 10ms > PE > 16ms > CE
+47ms ║Runtime (37249 bytes) successfully initialized in 10ms (v0.3.110.20191009) (46ms)
+48ms ║╔Execution stage started
+52ms ║║Cancelling statement #1’s schedules…
+58ms ║║null
+60ms ║║Executed virtual command log (3ms)
+66ms ║║Executed virtual command setVariable (3ms)
+68ms ║╚Execution stage complete. (20ms)
+69ms ╚Event processed successfully (69ms)


#6

I’m on my phone so can’t really get into detail but $response variable is only populated when webcore makes the web request. In your case, you’ll add a web request task calling the API that has info you need. Then another task to store or log the info received, $response.gallons


#7

Thanks for your response. This new piston gives the following log info, so now the question is how do I capture the 38 gallons.

Log:

+0ms ╔Received event [Home].execute = 161.35.74.221 with a delay of 163ms
+55ms ║RunTime Analysis CS > 21ms > PS > 14ms > PE > 20ms > CE
+57ms ║Runtime (37600 bytes) successfully initialized in 14ms (v0.3.110.20191009) (56ms)
+58ms ║╔Execution stage started
+62ms ║║Cancelling statement #1’s schedules…
+67ms ║║[doc_id:618ed47687559d00114c3fb0, event:doc.parsed, mailbox_id:618d536063b9710012ecbbf0, param1:execute, param2::723dd444e07f3602e30941747bbb7451:, payload:[parsed:[[name:gallons, value:38]], template_id:618ed31987559d00114c3d1f], remoteAddr:161.35.74.221]
+68ms ║║Executed virtual command log (2ms)
+76ms ║║Executed virtual command log (3ms)
+78ms ║║Cancelling statement #3’s schedules…
+84ms ║║Executed virtual command setVariable (4ms)
+86ms ║╚Execution stage complete. (28ms)
+87ms ╚Event processed successfully (87ms)

#8

I got the value to populate my variable, however I would prefer to eliminate the brackets in the result.

Logs:

+1ms ╔Received event [Home].execute = 161.35.74.221 with a delay of 127ms
+963ms ║RunTime Analysis CS > 923ms > PS > 19ms > PE > 20ms > CE
+965ms ║Runtime (37630 bytes) successfully initialized in 19ms (v0.3.110.20191009) (964ms)
+966ms ║╔Execution stage started
+970ms ║║Cancelling statement #1’s schedules…
+976ms ║║[doc_id:6190336487559d00114c7f6b, event:doc.parsed, mailbox_id:618d536063b9710012ecbbf0, param1:execute, param2::723dd444e07f3602e30941747bbb7451:, payload:[parsed:[[name:gallons, value:32]], template_id:618ed31987559d00114c3d1f], remoteAddr:161.35.74.221]
+976ms ║║Executed virtual command log (1ms)
+984ms ║║Executed virtual command log (3ms)
+987ms ║║Cancelling statement #3’s schedules…
+992ms ║║Executed virtual command setVariable (2ms)
+994ms ║╚Execution stage complete. (28ms)
+995ms ╚Event processed successfully (995ms)