0

I am using Twilio client to make phone calls with C++Builder (RAD Studio Tokyo) 10.2.3 and Intraweb 15.

To handle callbacks, this is the solution suggested by Twilio tech team:

https://www.twilio.com/docs/voice/make-calls#set-statuscallback-on-an-outbound-call

 async function createCall() {
  const call = await client.calls.create({
    from: "+18668675310",
    method: "GET",
    statusCallback: "https://www.myapp.com/events",
    statusCallbackMethod: "POST",
    to: "+14155551212",
    url: "http://demo.twilio.com/docs/voice.xml",
  });

  console.log(call.sid);
} 

The statusCallback is supposed to be a URL back to the web application built with Intraweb.

Using the Delphi Twilio Client, the phone call is made this way:

https://github.com/TwilioDevEd/twilio-delphi-demo/blob/master/TwilioClient.pas

allParams := TStringList.Create;
allParams.Add('From=' + fromPhoneNumber);
allParams.Add('To=' + toPhoneNumber);
allParams.Add('Url=http://demo.twilio.com/docs/voice.xml');

response := client.Post('Calls', allParams); 

The Twilio client is just a TNetHTTPRequest.

The problem is how to use the TNetHTTPRequest to handle the statusCallback so that I can get the result of the call back to my application?

1
  • OK. Thanks for the response
    – Louis
    Commented Aug 31 at 3:10

1 Answer 1

1

You don't handle the events with TNetHTTPRequest itself. It is just an HTTP client, it can't receive events, that is not how HTTP works (at least not in this case). Twilio will post separate HTTP requests to the specified callback URL, so you need an active HTTP server running at that URL to receive the events asynchronously, outside of your request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.