c# - How to call, Hang up, put on hold and unhold calls using Twilio? -


i have twilio number , understood in order 4 actions(call, hang up, put onhold , unhold calls) need create conference call, don't understand how add twilio number conference , how add number of mobile of client. example, if twilio number " +9728888888" , customer's want call mobile number "+9725555555" – want code examples of : 1. calling customer(from twilio number " +9728888888" mobile number "+9725555555") 2. hold call 3. unhold cold 4. hangout call.

i'm using twilio nuget on web api project. can give me code examples , considering numbers gave(twilio , mobile) of 4 scenarios above? appreciate it.

btw, saw code example on site:

using twilio.twiml;  class example {     static void main()     {         var response = new voiceresponse();         var dial = new dial();         dial.conference("moderated-conference-room",             startconferenceonenter: false);         response.dial(dial);          system.console.writeline(response.tostring());     } } 

but doesn't acknowledge twilio or mobile phone or twilio authentication i'm not sure how can work..

twilio developer evangelist here.

if want make call twilio number end user , put both agent , user conference call way it. not, however, c# developer, while i'll try give code samples i'm not experienced in .net web api projects.

you using twilio package nuget, that's start.

first up, need generate call agent , place them in conference call wait user. this, use twilio rest api place call. code looks bit this

const string accountsid = "acxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const string authtoken = "your_auth_token"; twilioclient.init(accountsid, authtoken);  var = new phonenumber("agent_phone_number"); var = new phonenumber("+9728888888"); var call = callresource.create(   to,   from,   url: new uri("http://example.com/conference") ); 

when call connects agent's number twilio make request url sent api. your application needs respond tell twilio call. in case, should put agent <conference> wait user. within action need generate call user.

public ihttpactionresult conference() {     // make call user     var = new phonenumber("+9725555555");     var = new phonenumber("+9728888888");     var call = callresource.create(       to,       from,       url: new uri("http://example.com/user_conference")     );     // return twiml     var response = new voiceresponse();     var dial = new dial();     dial.conference("conference", endconferenceonexit: true);     response.dial(dial);     ok(response.tostring()); } 

note: i've set agent side of conference endconferenceonexit: true. means when agent hangs up, conference call end participants.

now, twilio make call user , when connects ask new url call. time need respond twiml connect same conference. i'll leave deal with.

finally, to put participants on hold need use rest api again. need conference sid , sid of participant want put on hold. since putting user on hold agent, both of these sids in second webhook callback application.

with conference , call sid, make post request this:

    const string conferencesid = "conference_sid";     const string callsid = "call_sid";     participantresource.update(         conferencesid,         callsid,         hold: true,         holdurl: new uri("http://example.com/hold")     ); 

you can provide hold url can provide music while user waits. more information, check participant resource documentation. unholding user same process, set hold false.

let me know if gets on way creating feature.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -