Twilio only signal "free" SIP endpoints - twilio

I implemented twilio direct SIP calling with a SIP-Domain for in- and outbound with multiple SIP Clients using twilio functions without any additional PBX. Currently SIP inbound is configured in parallel, so all registered and online SIP endpoint ring. This is achieved with the following code fragment:
const dialer = twiml.dial({
ringTone: "de",
action: "https://...",
timeout: 25,
answerOnBridge: true,
callerId: event.From
})
dialer.sip('sip:accounta#demo1.sip.twilio.com');
dialer.sip('sip:accounta#demo2.sip.twilio.com');
dialer.sip('sip:accounta#demo3.sip.twilio.com');
Which is called on "Incoming Call" of the SIP-Domain. This works fine.
Currently all SIP phones ring when a new call comes in. Even the once which already are in an active call. Is there a way to only "ring" the SIP Endpoints currently not in a call, without running a full PBX? Maybe something like this?
Use Twilio Sync to "collect" the data, of all changing call status. Then use this data to only add the "free" sip endpoints in the code fragment above
Find a SIP softphone software, which "logs out" of SIP during a call. Doing this manually with MicroSIP client currently already works, but the agents need to manually login/logout on each call.
Any better solutions to this?

Find a SIP softphone software, which "logs out" of SIP during a call.
Softphone.Pro can "log out" while on call or ACW. It sends the SIP REGISTER Expires:0 message to your SIP server which means "unregister me immediately".
"UnregAccsForNA=1" configuration file parameter is what you need.

Related

Redirect an outbound call to an external sip (Watson)

I'm trying to re direct an ongoing outbound call to an external sip (Watson assistant - phone integration), while it seems to connect, i can't hear anithing on the other side.
Even when trying to do the redirect with a normal phone number it seems to connect, but the other phone doesn't even ring.
This is the code i'm using:
client.calls
.create({
twiml:'<Response><Dial><Sip>sips:+<NUMBER_IN_TWILIO>#public.voip.us-south.assistant.watson.cloud.ibm.com</Sip></Dial></Response>',
to: '<TARGET NUMBER>',
from: '<SAME_NUMBER_IN_TWILIO>'
})
.then(call => console.log(call.sid))
.catch(e => console.log(e));
For redirecting to regular numbers i just use:
<Response><Dial><Number> "OTHER NUMBER" </Number></Dial></Response>
Any tip is greatly appreciated!
All the best!
Saw this:
https://www.twilio.com/docs/voice/api/sip-interface
Note:
Twilio SIP Interface outbound call URI configurations using the sips URI scheme in order to enable end-to-end encryption is NOT supported by Twilio. However, we do support sip URI schemes using transport=tls for point-to-point encryption.
Also check your Twilio debugger for errors.

Twilio SIP: Calling to TwiML application on SIP endpoint

Apologies if I've missed something obvious, but...
I'm currently trying to use the Twilio REST API to create a call between a conference call and a video room - ie:
There exists a TwiML app to connect into a conference call (A)
There exists a video room (B)
There exists a SIP Domain (xxx.sip.twilio.com) with its Request URL set to a web service that produces TwiML to connect to the conference call A
I am attempting to join the two with an outgoing SIP call that calls the SIP endpoint and joins the video room
To create the call, I'm using the following code extract to create the call:
var call = CallResource.Create(
to: new Twilio.Types.PhoneNumber($"sip:xxx.sip.ie1.twilio.com?X-FriendlyName={FriendlyName}"),
from: new Twilio.Types.PhoneNumber("username2"),
sipAuthUsername: "xxx",
sipAuthPassword: "xxx",
url: new Uri("https://handler.twilio.com/twiml/<xxx>") // TwiML to connect to the video room
);
...which fails with: Error - 32009 - Dialing SIP Endpoint failure - User not registered
Not sure where to go from here - given the advice on the Twilio debugger indicates that it's the lack of a SIP client registered to the endpoint that's a problem... But there shouldn't be a SIP client involved? I'm just hoping to use the Twilio as a SIP endpoint in the same way as a phone number would be used - ie: to accept incoming calls and execute TwiML instructions.
Hopefully it's clear what I'm trying to ask :)
Twilio Registered SIP end-points must use the US1 region, so you need to modify the URL to be sip:xxx.sip.us1.twilio.com.
You can find more details on how to register a SIP end-point directly to Twilio HERE. The Voice URL for your SIP Domain would return TwiML which would add the SIP end-point as a voice participant using the Connect Verb (Connect a Call to a Room Code Example).

Bot Framework Twilio With Multiple Numbers

I have a bot that I've built that's running on the Azure Bot Service with a Twilio Channel. I'm sending Proactive activities via my Twilio channel. Everything is working fine. I just got a request that a customer wants to have their own phone number. I would like to just have 1 bot service running but have multiple Twilio phone numbers go into this.
My thought was that I could setup an API service which would then be the incoming message call back / webhook from Twilio which then would use the Directline API to the Bot Framework. It would essentially just replace the https://sms.botframework.com/api/sms service. The problem is that I'm not sure I could still have the proactive messages working - it seems like the Directline 3.0 API works only when a conversation is started first with it.
Does anyone have any thoughts on this if this would work or have any other ideas?
Thanks
Yes, the approach which you mentioned above would be ideal. Each Web App Bot/Bot Channels Registration can only be associated with one Twilio number. I will elaborate on the steps which you mentioned above:
Create a server running the Twilio SMS API code which forwards the messages to the bot via the DirectLine API. The user sends a message to this server.
For every activity sent to the bot, make sure to include the number: Activity.ChannelData = new { fromNumber: <123-456-7890> }. The Server forwards the message to the bot.
You will need to re-attach the fromNumber to the bot's outgoing activity so that your Twilio API server knows where to send the outgoing message to. The Bot sends the reply to the server.
The Twilio API server sends Activity.Text to the user. The Server forwards message from bot to user.
For the proactive messages part, you can add a conversation property to the address param, and set the id to the user's phone number.
Example:
bot.beginDialog(
{
user: { id: '+1234567890' },
bot: { id: '+9876543210' },
conversation: { id: '+1234567890' },
channelId: 'sms',
serviceUrl: 'https://sms.botframework.com'
},
);
Hope this helps.

Twilio Browser client Available or not

I am facing a problem with Twilio to detect the Twilio Browser client Available or not.
If Twilio client is not available then need to send the voicemail otherwise I am using to accept the call.
Twilio.Device.incoming(function (conn);
Thanks.
Sounds like you need agent presence. There are a couple ways to go about this. One (Recommended) is to use Twilio TaskRouter. https://www.twilio.com/taskrouter. This will handle agent presence for you (online, offline, busy, etc..) and much more
Your other option is to use a service like PubNub http://www.pubnub.com/ and bind the clint so you can get state information (online, offline, busy, etc..). This is more wok since you have to handle state yourself.
The following steps can be followed to achieve this
 1. Set a valid url to the action attribute of the Dial verb of the client
  Eg., The TwiMl to dial the client must be
  <Response>
   <Dial action="myapp/statusCallBack">
    <Client>jenny</Client>
   </Dial>
  </Response>
 2. If the client jenny is available, the connection object can be received via
  Twilio.Device.incoming(function (conn){conn.accept();});
 3. If the client jenny is unavailable, Twilio will request to the statusCallBack url with the parameter 'DialCallStatus=no-answer'. Now the following
  twiml can be returned to say Unavailable message.
  <Response>
   <Say>
    Please leave your name and number along with a short message.
   </Say>
   <Record maxLength="3600" action="myapp/recordedUrl">
   </Record>
  </Response>
 4. Now the voicemail url can be stored when the "myapp/recordedUrl" is called once the caller recorded the voicemail. For more info on record verb, visit this site
 Note that the voice mail is recorded on two cases, if the client is unavailable or the client does not accept the call.

How to set the From identifier for Twilio Client (VoIP) outgoing calls?

Our application accepts phone calls or VoIP connections via the twilio.js client into our twilio endpoint. Phone calls are logged by caller ID, but VoIP connections all appear as Anonymous in the twilio call log, e.g.:
Date Direction From To Type Status Recording Duration
XXYY Incoming Anonymous --- Client Completed --- 17 min 7 sec
YYZZ Incoming Anonymous --- Client Completed --- 17 min 23 sec
Is there a way to set the From field for outgoing (client->twilio) calls? Looked through Twilio.Device.connect as well as the capability token docs and couldn't find any hints.
It all ties into the capability token step, in a completely undocumented (and apparently unknown to Twilio themselves) manner.
In order to get the twilio logs to identify the VoIP endpoint that called into a conference, we had to bind the client ID to the allow_client_incoming capability, and make sure the ID was a straight alphanumeric (e.g. dashes in the string prevented the ID from coming through).
In our server side (ruby) token generation step, it looks something like this:
capability.allow_client_incoming sanitized_client_id
Twilio evangelist here.
When Client connects to your TwiML app endpoint, the From parameter that is passed to the Voice Request URL should be the name of the client.
If that Voice Request URL includes the <Dial> verb telling Twilio to make an outbound phone call and bridge it with the Client call, you can set the callerId parameter:
<Dial callerId="+15555555555" />
Hope that helps.
What worked for me was to set the clientName parameter in the OutgoingClientScope capability.
This is a code sample in js:
capability.addScope(
new ClientCapability.OutgoingClientScope({
clientName: 'mike',
applicationSid: 'AP...'
})
);
None of the other answers worked for me.

Resources