Twilio Dial verb speaks number instead of dialing outbound - twilio

I am currently working from a Twilio sub account and a TwiML app attempting to start an outbound call from a web based client.
I am using the Twilio. Device in the browser to connect to a landline. I have a public end-point exposed (using ngrok) and the TwiML App is successfully configured to POST the call request to the endpoint. I am responding with <Response><Say>Welcome to this call</Say><Dial>+1XXXXXXXXXX</Dial></Response>. When the client "connects" the system simply speaks the message and the number instead of dialing it and then hangs up. This happens regardless of the Say verb being present.
We do have conference calling working between to phone numbers, but getting this web client to call outbound is giving us a little trouble.
[REQUEST PARAMETERS: {"ApplicationSid":["APxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"],"ApiVersion":["2010-04-01"],"agent":["3xxxxxxxxx"],"Called":[""],"Caller":["client:Anonymous"],"CallStatus":["ringing"],"CallSid":["CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"],"To":["8xxxxxxxxx"],"From":["2xxxxxxxxx"],"Direction":["inbound"],"AccountSid":["ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]}]
[REQUEST HEADERS: {content-length=278, x-forwarded-proto=https, host=4dxxxxxxx.ngrok.io, content-type=application/x-www-form-urlencoded; charset=UTF-8, connection=close, x-forwarded-for=xxx.xxx.229.114, cache-control=max-age=259200, x-twilio-signature=lflllCdXo004m0wRzw/efN0IAjg=, user-agent=TwilioProxy/1.1}]

Well, feel a like a newbie, but I had forgot to set the content type to one of the required Content-Type headers, text/xml, text/html, or application/xml. With the header in the response Twilio connects the call as expected.

Related

Twilio Voice hava script sdk, When dial we can send param But how to send Authorization key in the header?

https://github.com/TwilioDevEd/voice-javascript-sdk-quickstart-node
I have referred to the standard Twilio example to make a call from the browser, I was able to implement calling.
const call = await device.connect({ params });
where params are the body of the post request, But is there any way where we can attach a header to this post request?
Twilio developer evangelist here.
Using the SDK to start a call isn't an HTTP request. It results in a webhook request from Twilio to your application, but that is different to the initial request from the SDK. You can use the SDK to pass POST request parameters as you have seen, but you cannot pass headers.
If you are trying to pass an Authorization header, then I assume you are trying to ensure that only requests from Twilio are accepted by your application. There's already a way to do this.
Twilio sends an X-Twilio-Signature header with each webhook request. The signature is made up of the contents of the request signed with your Twilio auth token. You can read how this works in depth here.
Alternatively, you can add username:password# to the start of the webhook URL and Twilio will authenticate via HTTP authentication.

Twilio SIP Trunking and Sip Domain

I am currently using Twilio for my cloud communication platform. A client of ours wants to SIP over to us, with headers, so we can continue the call on our end using Twiml.
I have tried setting up a SIP Domain and it works if I use a soft phone for an end point, but this isn't what I am trying to accomplish. I have also tried setting up a SIP Elastic Trunk and have that trunk connect to our SIP domain which in return call the Voice URL on the SIP domain.
I currently have setup a simple application to test this process. I have a Twilio number that calls a webhook, in the webhook (my app) I call the sip to the Twilio SIP trunk, but it fails. I am expecting to call the SIP domain and the Voice URL. I keep getting the error that the You tried to Dial a SIP Endpoint that is not currently registered with the corresponding SIP Domain. Please check your TwiML or REST API. (reference: TWilio Error Documentation.
Can anyone help me with this, please? I am currently using Twiml with PHP.
-- Update --
I am also following this documentation to a tee. I have a SIP Domain setup in my Twilio account, but it is requiring a registered user at an endpoint. In this documentation, it says when a sip call comes into the sip domain it will call the webhook, which it is not doing. Twilio SIP Domains
Twilio developer evangelist here.
I believe you're right to be confused about the SIP domain documentation. But the error message clears it up when it says:
Make sure the username matches a username in the Credential List used to authenticate the SIP Endpoint with the SIP Domain.
So your username does need to be an existing one, the SIP domain is not acting as a wildcard catch all for SIP addresses.
I will work to make sure the documentation is clearer.
Given that you are already receiving a webhook from an incoming call, why are you trying to get a second webhook from the SIP request? Could you not use the first webhook to direct the call the way you need?
In general, if you try to call a SIP endpoint via a SIP server/proxy, that SIP server/proxy needs to know how to reach that endpoint (routing). From the error text I derive that that isn't possible at the moment. Also, sometimes SIP servers only allow outbound calls from registered endpoints.
There are a number of things you can do:
Bypass the SIP server and call the endpoint directly (probably not what you want)
Configure a static path in the SIP server to the endpoint
Have the endpoint(s) register at the SIP server, so the SIP server knows who calls and how to reach the target.
Have you tried the possible solutions in the Error documentation?
Make sure the username (in the Request-URI) matches a username in the Credential List used to authenticate the SIP Endpoint with the SIP Domain
Prior to dialing, you can verify that your SIP Endpoint has successfully registered in the Console "Registered SIP Endpoints" tab found on the SIP Domains page.

Twilio webhook (NodeJS) - On inbound call, pass call's SID

I'm looking to have the webhook which I pass back TwiML whenever there's a call coming inbound pass me the call's SID so in the future I can modify that active in-bound call. For example, (480)-000-000 is calling my Twilio number which then sets off the webhook to retrieve the TwiML. My server will then also get the SID for that call coming in, and send back TwiML to play lobby music. From then my server will have the SID stored into an array for people in the lobby. And one by one connect them with agents as they become open.
Twilio developer evangelist here.
Good news, every webhook for an incoming voice call to your Twilio number includes the CallSid in the request parameters.
The parameters are sent to your URL as URL encoded form data so if you're using a web framework it should be fairly straightforward to read the CallSid from the request.
Let me know if that helps!

401 Not Authorized when using Twilio Enqueue verb with HTTP Basic Auth

When a user calls my number, Twilio makes a request of the format https://username:password#www.myserver.com/my_secure_document to my servers, which are protected by HTTP Basic Auth. This works great - Twilio logs in, sees an Enqueue verb, and remains logged in as it follows the waitURL.
However, after the user is dequeued by the other person hanging up (in this case, a Twilio Client), the Enqueue action URL is getting 401 Not Authorized responses. Is this a bug in Twilio? The docs say that "Twilio will authenticate to your web server using the provided username and password and will remain logged in for the duration of the call". Shouldn't following the action of an Enqueue count as part of the call?
Well, here's the workaround that worked for me: convert the action URL from a relative path to an absolute path, and provide the HTTP basic auth credentials again.

Is it possible to send a cookie with a SMSMessage using the Twilio-csharp / TwilioRestClient?

I am creating outbound SMS communication and need to set a cookie so I can track the conversation thread. I'm using the Twilio-charp client and did not see a way to set a cookie or and http header. Is this possible or do I need to pursue a different route?
Edit:
I need to elucidate here. In my scenario I need to set a cookie with a transaction id that needs to included in the originating outbound message. For example I will be creating an SMS message that will request a response from the user: "Text (1) to approve, (2) to decline".
The Twilio sample code details a page that receives a message, checks for a cookie, then creates one if it does not already exist. In my scenario I need the cookie to be in the outbound message.
I contacted support at Twilio and they stated that cookies can not be sent with their REST API. Cookies can be exchanged from the response endpoint that you create where you set the http header.
This means that you must wait for the user to reply to your first message before you can insert cookies to the http headers.
You can definitely set a cookie to track the conversation thread. Details and sample code can be found here under Twilio's .NET (C#) quickstarts: http://www.twilio.com/docs/quickstart/csharp/sms/tracking-conversations

Resources