'How can i get the call-sid from response of callback in twilios AddOn's "IBM Watson"

We enable the Twilios AddOn "IBM Watson Speech to Text" for recording transcribe.and we set our server webhook while enabling the addon. Now twilio calling webhook once call is completely done. after completing call twilio give response in that webhook In Nodejs.For handling that call response we need "Call Sid".In webhook response we cannot get "callSid".So how we can identify that response is for this particular call...?

anyone help me to how can find call-sid in response?

Callback response is

{
    "status": "successful",
    "message": null,
    "code": null,
    "results": {
        "ibm_watson_speechtotext": {
            "request_sid": "**************",
            "status": "successful",
            "message": null,
            "code": null,
            "payload": [{
                "content_type": "application/json",
                "url": "*************/Data"
            }],
            "links": {
                "add_on_result": "***********/Accounts/********/Recordings/**********/AddOnResults/******",
                "payloads": "https://api.twilio.com/2010-04-01/Accounts/******/Recordings/*******/AddOnResults/******/Payloads",
                "recording": "https://api.twilio.com/2010-04-01/Accounts/******/Recordings/*******"
            }
        }
    }
}

Thank you for help



Solution 1:[1]

When you get the Add-on result it comes as part of the Twilio voice webhook, with all the normal request parameters as well as an extra AddOns parameter which contains the JSON that you have shared above.

Webhook requests from Twilio are in the format application/x-www-form-urlencoded and then within the AddOns parameter the data is a JSON string. In a (Ruby-like) pseudo code, you can access the call sid and the add on data like this:

post "/webhook" do
  call_sid = params["CallSid"]
  add_on_json = params["AddOns"]
  add_on_data = JSON.parse(add_on_json)
 
  # return TwiML
end

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 philnash