Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • FAQs

Parsing Webhook Responses in TrackDrive

Written by Rich Nolan

Updated at December 5th, 2023

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Getting Started
  • Integrations
  • API Documentation
  • Knowledge Base
  • FAQs
  • Features
  • Blog
  • TrackDrive Tools
+ More

 

Parsing a Webhook Response

(how to search the response for a field name)

 

When you interface with Buyers, Traffic Sources, other Platforms, etc, this is done with something called a “webhook”.  Webhooks and responses to those are how different platforms talk with each other, and for each Webhook REQUEST, there will be a Webhook RESPONSE.

 

This article describes how to find the field name that you are looking to store the value of or check to see if it is the correct value.  For example: “result”: “success” may have to be checked to know a buyer received and accepted a lead before sending a call.

 

Example:

 

Webhook REQUEST: https://buyerdomain.com/add_lead/?caller_id=7195220111&first_name=John&last_name=Smith&zip=80920

 

Webhook RESPONSE in JSON: 

{
    "results": {
        "data": {
            "outcome": "success",
            "lead": {
                "id": "647608da63aa7dcdba357dcc"
            }
        },
        "price": 120
    },
    "category": "warm_transfer"
}

 

Webhook RESPONSE in XML:

<?xml version="1.0" encoding="UTF-8" ?>
<root>
   <results>
       <data>
           <outcome>success</outcome>
           <lead>
               <id>647608da63aa7dcdba357dcc</id>
           </lead>
       </data>
       <price>120</price>
   </results>
   <category>warm_transfer</category>
</root>

It is easiest to explain that some fields are at the ROOT of the RESPONSE (JSON Only, XML must have an outer ROOT field name (by default most system will use <root>XML HERE</root>, but the ROOT variable name can be anything).  In summary, if a field is at the root, you parse to it just by its name, but for each field inside a nest field must include that field name to the path of the field you are looking for.

It is easiest to show this in the two below pictures:

JSON

As Used in TrackDrive

For the above example, we put in the webhook parsing the check if the buyer accepted the data, the following:

Was The Response Acceptable: 200,201

Extract Value From Response Body: results.data.outcome

Check If Response/Extracted Value Contains: success

 

XML

As Used in TrackDrive

For the above example, we put in the webhook parsing the check if the buyer accepted the data, the following:

Was The Response Acceptable: 200,201

Extract Value From Response Body: root.results.data.outcome

Check If Response/Extracted Value Contains: success

 

NOTE: Some systems only return a string.  You will not be able to parse to a field name in that case, but rather just search for the data value to exists.  To parse the entire string you put the path to the field name as just “.” to grab the entire response, then you could use formulas to get the data out of the string, but most companies follow good coding and will return the RESPONSE in either JSON or XML.

 

You will at times get a response that has an Array of fields in it, so parsing is a bit different when you see square brackets in the response.  For Example: buyers: below has a square bracket, so you then have to parse thru an array.

 

For example the Response from a PING to check for buyers will have a Buyer Array in it and might look something like this:

 

{
   "data": {
       "success": true,          <~~~~~~~~ data.success
       "status": "accepted",
       "errors": [],
       "buyers": [
           {
               "ping_id": "6cdb9f01-3bf9-4651-b50a-9babe8c2ddbd",
               "id": 10299745,     <~~~~~~~~~~ data.buyers[0].id
               "forwarding_number": "+17192392277",
               "offer_conversion_payout": 5,    <~~~~~~~~~ data.buyers[0].offer_conversion_payout
               "offer_conversion_duration": 60,
               "offer_conversion_dedupe_seconds": 43200
           },
           {
               "ping_id": "d045a435-2828-4218-bae4-7c4d3c1fb368",
               "id": 10299756,    <~~~~~~~~~~ data.buyers[1].id
               "offer_conversion_payout": 5,   <~~~~~~~~~ data.buyers[1].offer_conversion_payout
               "offer_conversion_duration": 60,
               "offer_conversion_dedupe_seconds": 43200
           },
           {   <~~~~~~~~~ Everything between here and the } would be data.buyers[2].FIELDNAME_TO_PARSE
               "ping_id": "82ebd763-48aa-460a-bc92-f033bc1bb1ad", <~~~~~~~~~~ data.buyers[2].ping.id
               "id": 10299772,   <~~~~~~~~~~ data.buyers[2].id
               "offer_conversion_payout": 5,   <~~~~~~~~~~ data.buyers[2].offer_conversion_payout
               "offer_conversion_duration": 60, <~~~~~~~~~~ data.buyers[2].offer_conversion_duration
               "offer_conversion_dedupe_seconds": 43200  <~~~~~~ data.buyers[2].offer_conversion_dedupe_seconds
           }
       ],
       "call_router_id": 66453  <~~~~~~~~~ data.call_router_id
   },
   "send_call": true     <~~~~ send_call (notice this is not inside of the “data” so it is parsed using just name of field
}

parsing webhooks

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • What IP Addresses Does TrackDrive Need Whitelisted?
  • Why do my numbers show Spam when calling a lead?
  • How Can I Tell If My Traffic Source has Real Leads?
  • Why is My Buyer Telling Me They Didn't Get a Call?
  • Trackdrive

    Powerful call analytics and web-lead to inbound call automation.

    • call (855) 387-8288
    • mail support@trackdrive.net
    • warning Submit A Ticket
  • Important Links

    Features Careers Blog Terms of Service Privacy Policy GDPR Policy Brand Kit
  • Features

    Call Tracking Lead to Call Automation Hold Queue & Caller Callback Multiple Phone Providers Dynamic Number Insertion Real-Time Bidding Advertising Optimizer Bulk SMS Comprehensive REST API
  • Developers

    REST API Docs Number Insertion Docs System Status

Knowledge Base Software powered by Helpjuice

© 2022 All Rights Reserved.

Definition by Author

0
0
Expand