What can be wrong when the Webhook is deserialized?

hi!
I would greatly appreciate your help solving this case.
I have been trying for several days to pass my webhook directly to the WhatsApp application, and although the Webhook is perfectly formed and verified in several other JSON evaluation platforms, however, I cannot reference the elements when the Webhook is dynamic through POST from my application source

I found this differences:

Encode Sending (I put it here in parentheses)
(%7B%22Events%22%3A%5B%7B%22Type%22%3A%22Intrn%22%2C%22Devices%22%3A%22Ext±%3E+Ext%22%2C%22Status%22%3A%22Up%5C%2FUp%22%2C%22PeerA%22%3A%22SIP%5C%2F102%22%2C%22PeerB%22%3A%22SIP%5C%2F100%22%2C%22Ring%22%3A%223%22%2C%22MOH%22%3A%22%5C%2F0%22%2C%22HV%22%3A%2200%22%2C%22CallerID%22%3A%22102%22%2C%22Dial%22%3A%22100%22%2C%22HunterID%22%3A%22Llamada+Interna%22%2C%22Duration%22%3A%2200%3A00%3A01%22%2C%22AlarmBlock%22%3A%22ANS%3AExt%3ASIP%5C%2F100%22%2C%22CallUID%22%3A%221629080540.56%22%2C%22LinkUID%22%3A%221629080540.56%22%2C%22TStampEvent%22%3A%221629080540%22%2C%22Channel-Orig%22%3A%22SIP%5C%2F102-00000038%22%2C%22Channel-Dest%22%3A%22SIP%5C%2F100-00000039%22%2C%22IP-Orig%22%3A%2210.10.11.7%3A5060%22%2C%22IP-Dest%22%3A%2210.10.11.10%3A49203%22%2C%22TimeStamp%22%3A%2220210815212227%22%7D%5D%7D)

Original Webhook (I put it here in parentheses)
({“Events”:[{“Type”:“Intrn”,“Devices”:“Ext → Ext”,“Status”:“Up/Up”,“PeerA”:“SIP/102”,“PeerB”:“SIP/100”,“Ring”:“3”,“MOH”:"/0",“HV”:“00”,“CallerID”:“102”,“Dial”:“100”,“HunterID”:“Llamada Interna”,“Duration”:“00:00:01”,“AlarmBlock”:“ANS:Ext:SIP/100”,“CallUID”:“1629080540.56”,“LinkUID”:“1629080540.56”,“TStampEvent”:“1629080540”,“Channel-Orig”:“SIP/102-00000038”,“Channel-Dest”:“SIP/100-00000039”,“IP-Orig”:“10.10.11.7:5060”,“IP-Dest”:“10.10.11.10:49203”,“TimeStamp”:“20210815212227”}]})

steps.trigger.event.body (I put it here in parentheses)
({"{“Events”:[{“Type”:“Intrn”,“Devices”:“Ext → Ext”,“Status”:“Up\/Up”,“PeerA”:“SIP\/102”,“PeerB”:“SIP\/100”,“Ring”:“3”,“MOH”:"\/0",“HV”:“00”,“CallerID”:“102”,“Dial”:“100”,“HunterID”:“Llamada Interna”,“Duration”:“00:00:01”,“AlarmBlock”:“ANS:Ext:SIP\/100”,“CallUID”:“1629080540.56”,“LinkUID”:“1629080540.56”,“TStampEvent”:“1629080540”,“Channel-Orig”:“SIP\/102-00000038”,“Channel-Dest”:“SIP\/100-00000039”,“IP-Orig”:“10.10.11.7:5060”,“IP-Dest”:“10.10.11.10:49203”,“TimeStamp”:“20210815212227”}]}":null})

I don’t know what can be wrong here ?
When the Webhook is deserialized, there must be some problem and since I don’t have much experience in JS, the truth is that I have not managed to fix the problem, not even with some recommendations of similar cases in the forum

I really appreciate if you give me a hand to continue with this platform that I like so much and I find it very useful for my projects
Greetings

Hi @lfeche , it’s the encoding that’s tripping up our parser. But you can always access the raw data sent in the HTTP payload at steps.trigger.raw_event.body_b64, where the automated parsing of the incoming payload fails. I’d recommend trying this:

JSON.parse(decodeURIComponent(steps.trigger.raw_event.body_b64))

Let me know if that works.

1 Like

Thanks for the answer, it sure will help me.
or maybe :slight_smile:
I’m going to try it, Greetings!

Hi there!

Everything would be perfect to practice and learn a little more, only that I have been preparing a test demo for a client for more than a week and this is a component of the integration with webhooks within several components, and although I think I can finish tomorrow, It is possible that I will not achieve this aspect, because I do not have enough experience at that level to compose the data that fails when entering the platform …

Surely for you with your knowledge of the platform it is simpler, I exhaust all the invocations in other tests that I do and now I do not have much opportunity to test

Is it possible for you to give me a hand and help me to resolve this impasse so that the JSON reception operation is carried out properly, and I can then make my complete presentation? :slight_smile:
It would be very valuable for me to have this resolved and to be able to do the demo
Since yesterday I shared my work area with Dylan, I don’t know if he can take a look at this matter, please :slight_smile:
Apologies for my “emergency”, I feel sorry :frowning: :see_no_evil:

Ohhh, you are Dylan! :roll_eyes:

Hi @lfeche , what specifically do you need help with?

Hi Dylan, thanks for your attention!
I only need the implementation of the step where I can have the original complete reference to the body of the Webhooks sent, and that can arrive in internal structures of various types, since “Events”, “Alarms”, “Messages” and others are sent, all within of the same JSON, and each one with the possibility of up to 16 internal arrangements, as I say, all within a single JSON, all of the above of course, if the various types of events occur in the update intervals, which is one second in the system …
If it is possible for the JSON to be fully recognized in its original format in a previous step that you help me to fix the received data, I can do the rest, although for now for the matter of the Demo, I will only focus in Events content []
Examples of the data can be seen in the current records of the shared project, the most important for the case that I am telling you, is when Events [] are presented, but of course, it would be better to receive the entire body of the JSON as a single JSON and I commission of the rest …
Thanks a lot!

hi there, im in a similar scenario! (exactly for a whatsapp bot) i need to send an url to an api, and it works great unless i start using variables, with parse weird, and then i get a 4XX error.

Hi @rmorales , which 4XX error specifically are you seeing (400, 401, etc.)?

it worked on the url level, but i have a problem since i have an static value, and i always need to return the last value recorded in google sheets, but now, on a text, i get [object Object] in the text I’m parsing

https://live-server-2516.wati.io/api/v1/sendSessionMessage/{{event.currentValues.values[2][1]}}

its what I’m sending in the URL, i shoud send .values[event-1(**** not the proper syntax)][1]

and the query parameter looks like this:

Tú compra ha sido registrada con el número {{event}}

its not a 4XX error, i get the following error message:

TypeError: Cannot read property ‘1’ of undefined
at eval (eval at _pd_deep_evaluate (/opt/nodejs/node_modules/@pipedreamhq/execution-environment/params_evaluator.js:63:16), :1:92)
at _pd_deep_evaluate (/opt/nodejs/node_modules/@pipedreamhq/execution-environment/params_evaluator.js:63:16)
at MessagePort. (/opt/nodejs/node_modules/@pipedreamhq/execution-environment/params_evaluator.js:11:9)
at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:399:24)
at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26)