Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var builder = new  ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.local.json", optional: true) // for storing actual information
            ;
            IConfigurationRoot configuration = builder.Build();
            string             Account       = (configuration.GetSection("TwilioSettings:Account").Value);
            string             Token         = (configuration.GetSection("TwilioSettings:Token").Value);
            string             username      = (configuration.GetSection("TwilioSettings:Username").Value);
            string             password      = (configuration.GetSection("TwilioSettings:Password").Value);
            string             phoneNumber   = (configuration.GetSection("TwilioSettings:DefaultNumber").Value);

            TwilioClient.Init(Account, Token);
            var    from        = new Twilio.Types.PhoneNumber(phoneNumber);
            var    to          = new PhoneNumber("+19725239489");
            string MessageBody = "Join Earth's mightiest heroes. Like Kevin Bacon.";

            var message = MessageResource.Create(body: "Join Earth's mightiest heroes. Like Kevin Bacon.", from: from, to: to);

            Console.WriteLine($"{message.Sid}  - {message.Status}");
            var call = CallResource.Create(to, from, url: new Uri("http://demo.twilio.com/docs/voice.xml"));

            Console.WriteLine($"{call.Sid}  - {call.Status}");
        }
        public ActionResult ScheduleCall(AddressBookModel model)
        {
            string accountSid = ConfigurationManager.AppSettings["Twilio:Sid"].ToString();
            string authToken  = ConfigurationManager.AppSettings["Twilio:AuthToken"].ToString();
            string fromNumber = ConfigurationManager.AppSettings["Twilio:FromNumber"].ToString();

            TwilioClient.Init(accountSid, authToken);

            var to   = new PhoneNumber(model.MobileNumber);
            var from = new PhoneNumber(fromNumber);

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
                                                   | SecurityProtocolType.Tls11
                                                   | SecurityProtocolType.Tls12
                                                   | SecurityProtocolType.Ssl3;


            var gatherStr = $"<Gather input='speech dtmf' action='/AddressBook/Gather' finishOnKey='1' numDigits='1' timeout='5' length='5'><Say>Please press 1 to confirm you have understood the message</Say></Gather>";//<Say>We didn't receive any input. Goodbye!</Say>";

            var call = CallResource.Create(
                twiml: new Twilio.Types.Twiml($"<Response><Say>{model.Message}</Say>{gatherStr}<Pause length='3'/>{gatherStr}</Response>"),
                //twiml: new Twilio.Types.Twiml($"<Response><Say>{model.Message}</Say>{gatherStr}<Pause length='5'/>{gatherStr}</Response>"),
                to: new Twilio.Types.PhoneNumber(model.MobileNumber),
                from: new Twilio.Types.PhoneNumber(fromNumber)
                );



            Console.WriteLine(call.Sid);

            //DbData objDB = new DbData(); //calling class DBdata
            //var result = objDB.GetAddressBookDataByID(Id); // get values for editing
            ViewBag.Message = "Success";
            return(View(new AddressBookModel()));
        }
        public ActionResult MakeCall()
        {
            var accountSid = _configurationUtility.TwilioAccountSid;
            var authToken  = _configurationUtility.TwilioAuthToken;

            TwilioClient.Init(accountSid, authToken);

            var to   = new PhoneNumber(_configurationUtility.MyPhoneNumber);
            var from = _configurationUtility.TwilioNumber;
            var statusCallbackEvents = new List <string>()
            {
                "initiated",
                "ringing",
                "answered",
                "completed"
            };

            var call = CallResource.Create(
                to: to,
                from: from,
                url: new Uri("http://demo.twilio.com/docs/voice.xml"),
                method: new HttpMethod("GET"),
                statusCallback: new Uri("http://raise.us-west-2.elasticbeanstalk.com/phone/callback"),
                statusCallbackMethod: new HttpMethod("POST"),
                statusCallbackEvent: statusCallbackEvents);

            return(Content(call.Sid));
        }
Exemplo n.º 4
0
        public IActionResult Index()
        {
            var accountSid = _config["TwilioSetting:accountSid"];
            var authToken  = _config["TwilioSetting:authToken"];

            var toPhoneNumber   = _config["TwilioSetting:to"];
            var fromPhoneNumber = _config["TwilioSetting:from"];

            TwilioClient.Init(accountSid, authToken);
            // TwilioClient.Init(accountSidTest, authTokenTest);

            // 請填入正確的電話號碼
            var to = new PhoneNumber(toPhoneNumber);

            var from = new PhoneNumber(fromPhoneNumber);

            var url = $"https://conversationtemplate.azurewebsites.net/VoiceTest";
            // var url = $"https://almond-vulture-8773.twil.io/facts";

            var call = CallResource.Create(
                to: to,
                from: from,
                url: new Uri(url)
                );

            //var call = IncomingPhoneNumberResource.Create(
            //    phoneNumber: from,
            //    voiceUrl: new Uri("http://demo.twilio.com/docs/voice.xml")
            //    );
            return(Content(call.Sid));
        }
Exemplo n.º 5
0
        /// <summary>
        /// To run this application, the following is required:
        ///
        /// - API token key/secret from Account -> Developer -> API Tokens
        /// - A verified Caller ID UUID from Account -> Telephony -> Caller IDs -> Edit (in the URI)
        /// - Fill in variables to run example
        /// </summary>
        /// <param name="args"></param>
        async static Task Main(string[] args)
        {
            // Initialize `OmnigageClient` using settings from "appsettings.json"
            // Alternatively, this line can be commented out and use `OmnigageClient.Init()`
            // to set config
            Util.Init();

            // Set the Caller ID (e.g., NeSB5RN8gbT6ZtmZYdYWpH)
            var callerId = "";

            // Recipient phone number
            var to = ""; // In E.164 format (such as +1xxxxxxxxx)

            var call = new CallResource
            {
                To       = to,
                Action   = CallAction.Dial,
                CallerId = new CallerIdResource
                {
                    Id = callerId
                }
            };

            await call.Create();
        }
Exemplo n.º 6
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            //Acquire number to call from querystring/body
            string number = req.Query["number"];

            string  requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);

            number = number ?? data?.number;

            log.LogInformation(number);

            //Get Twilio account specific info from Environment Variables
            string accountSid = Environment.GetEnvironmentVariable("TwilioAccountSID");
            string authToken  = Environment.GetEnvironmentVariable("TwilioAuthToken");
            string fromNumber = Environment.GetEnvironmentVariable("TwilioFromNumber");

            //Init Twilio
            TwilioClient.Init(accountSid, authToken);

            PhoneNumber to   = new PhoneNumber(number);
            PhoneNumber from = new PhoneNumber(fromNumber);
            var         call = CallResource.Create(to, from,
                                                   url: new Uri("http://demo.twilio.com/docs/voice.xml"));

            log.LogInformation(call.Sid);

            return(number != null
                ? (ActionResult) new OkObjectResult(call.Sid)
                : new BadRequestObjectResult("Please pass a number to call on the query string or in the request body"));
        }
Exemplo n.º 7
0
        public void MakeCall(string personName)
        {
            // Your Account SID from twilio.com/console
//            var accountSid = "AC1f05db609ba8398a8b1c3664fb8f38d0";
            var accountSid = "AC1c716f11155003f530c56e4bacf44566";

            // Your Auth Token from twilio.com/console
//            var authToken = "d82287ecde01621d6a97454ed3ae12c0";
            var authToken = "b9a42e2a4902c4946e35062bcbfa0e91";

            try
            {
                TwilioClient.Init(accountSid, authToken);

                var call = CallResource.Create(
                    to: new PhoneNumber("+2348036420271"),
                    //to: new PhoneNumber("+2347037736311"),
                    from: new PhoneNumber("+12622870316"),
                    url: new Uri("https://018d5d5b.ngrok.io/ids.ng/voice.xml"));

                string callID = call.Sid.ToString();
            }
            catch (Exception n)
            {
            }
        }
Exemplo n.º 8
0
        public void MakeCall()
        {
            // Your Account SID from twilio.com/console
            var accountSid = "AC1f05db609ba8398a8b1c3664fb8f38d0";

            // Your Auth Token from twilio.com/console
            var authToken = "d82287ecde01621d6a97454ed3ae12c0";

            try
            {
                TwilioClient.Init(accountSid, authToken);

                var call = CallResource.Create(
                    to: new PhoneNumber("+2348036420271"),
                    from: new PhoneNumber("+2347037736311"),
                    url: new Uri("http://27276fbf.ngrok.io/default/"));

                //Console.WriteLine(call.Sid.ToString());
                //Console.Write("Press any key to continue.");
                //Console.ReadKey();
            }
            catch (Exception n)
            {
            }
        }
Exemplo n.º 9
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var to   = new PhoneNumber("+14155551212");
        var from = new PhoneNumber("+18668675309");
        var statusCallbackEvents = new List <string>()
        {
            "initiated",
            "ringing",
            "answered",
            "completed"
        };

        var call = CallResource.Create(
            to,
            from,
            url: new Uri("http://demo.twilio.com/docs/voice.xml"),
            method: new HttpMethod("GET"),
            statusCallback: new Uri("https://www.myapp.com/events"),
            statusCallbackMethod: new HttpMethod("POST"),
            statusCallbackEvent: statusCallbackEvents);

        Console.WriteLine(call.Sid);
    }
Exemplo n.º 10
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/console
        // To set up environmental variables, see http://twil.io/secure
        const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        const string authToken  = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var to   = new PhoneNumber("+14155551212");
        var from = new PhoneNumber("+18668675310");
        var statusCallbackEvents = new List <EventEnum>()
        {
            EventEnum.Initiated,
            EventEnum.Ringing,
            EventEnum.Answered,
            EventEnum.Completed
        };
        var call = CallResource.Create(
            to,
            from,
            url: new Uri("http://demo.twilio.com/docs/voice.xml"),
            statusCallback: new Uri("https://www.myapp.com/events"),
            statusCallbackMethod: HttpMethod.Post,
            statusCallbackEvent: statusCallbackEvents);

        Console.WriteLine(call.Sid);
    }
Exemplo n.º 11
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("Twilio call started");

            string  requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data        = JsonConvert.DeserializeObject(requestBody);
            string  toNumber    = data?.To;

            if (toNumber != null)
            {
                const string accountSid = "<ACCOUNT>";
                const string authToken  = "<TOKEN>";
                TwilioClient.Init(accountSid, authToken);

                var to   = new PhoneNumber(toNumber);
                var from = new PhoneNumber("+18064549797");
                var call = CallResource.Create(to, from,
                                               url: new Uri("https://jjfunctionv2.azurewebsites.net/api/twilio_call_response"));
                //url: new Uri("http://demo.twilio.com/docs/voice.xml"));
            }

            return(toNumber == null
                ? new BadRequestObjectResult("Please pass a To in the request body")
                : (ActionResult) new OkObjectResult("Calling..."));
        }
Exemplo n.º 12
0
        public void MakePhoneCall(Notification notification)
        {
            var p = DatabasePatientService.GetById(notification.PatientId);

            p.LoadUserData();
            if (testTwilio)
            {
                var to           = new PhoneNumber(p.Phone);
                var from         = new PhoneNumber("+14052469892");
                Uri callback_url = null;
                switch (notification.Type)
                {
                case Notification.NotificationType.Refill:
                    callback_url = new Uri("http://ocharambe.localtunnel.me/twilioresponse/refill/" + notification.NotificationId);
                    break;

                case Notification.NotificationType.Ready:
                    callback_url = new Uri("http://ocharambe.localtunnel.me/twilioresponse/ready/" + notification.NotificationId);
                    break;

                case Notification.NotificationType.Birthday:
                    callback_url = new Uri("http://ocharambe.localtunnel.me/twilioresponse/birthday" + notification.NotificationId);
                    break;
                }
                var call = CallResource.Create(to,
                                               from,
                                               url: callback_url);
            }
        }
Exemplo n.º 13
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var statusCallbackEvent = new List <string> {
            "initiated",
            "answered"
        };

        var call = CallResource.Create(
            method: Twilio.Http.HttpMethod.Get,
            statusCallback: new Uri("https://www.myapp.com/events"),
            statusCallbackEvent: statusCallbackEvent,
            statusCallbackMethod: Twilio.Http.HttpMethod.Post,
            url: new Uri("http://demo.twilio.com/docs/voice.xml"),
            to: new Twilio.Types.PhoneNumber("+14155551212"),
            from: new Twilio.Types.PhoneNumber("+18668675310")
            );

        Console.WriteLine(call.Sid);
    }
Exemplo n.º 14
0
        public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "StartCall")] HttpRequestMessage req)
        {
            var configuration = new HttpConfiguration();

            req.SetConfiguration(configuration);

            var phoneNumberToCall = new PhoneNumber("+");

            // Find your Account Sid and Auth Token at twilio.com/console
            var twilioAccountSid = "";
            var twilioAuthToken  = "";

            // Find your Programable Voice app sid at twilio.com/console
            var twilioProgVoiceApplicationSid = "";

            var phoneNumberCallIsFrom = "+";

            TwilioClient.Init(twilioAccountSid, twilioAuthToken);
            var call = CallResource.Create(phoneNumberToCall, phoneNumberCallIsFrom, applicationSid: twilioProgVoiceApplicationSid, record: true, recordingChannels: "dual");

            System.Diagnostics.Debug.WriteLine("Call Sid is: " + call.Sid);

            var callSid = call.Sid;

            return(req.CreateResponse(HttpStatusCode.OK, callSid));
        }
Exemplo n.º 15
0
        public void CallProbationReminder()
        {
            var instructionsXml2 = ConfigurationManager.AppSettings["TwilioInstructionsXML2"];

            TwilioClient.Init(_twilioAccountSid, _twilioToken);
            // this is Harper
            var call = CallResource.Create(new PhoneNumber("8045064006"), _twilioFrom, url: new Uri(instructionsXml2), method: HttpMethod.Get);
        }
        public async Task <object> Call(string to)
        {
            var receiver = new PhoneNumber(to);
            var from     = new PhoneNumber(_configuration["Twilio:Sender"]);

            var call = CallResource.Create(receiver, from, url: new Uri("https://jet-echidna-4440.twil.io/assets/CallVerefication.xml"));

            return(call);
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            TwilioClient.Init("username", "password");
            TwilioClient.SetRestClient(new TwilioEmulatorRestClient(TwilioClient.GetRestClient(), new Uri("http://localhost:5000")));

            var call = CallResource.Create(new PhoneNumber("12345"), new PhoneNumber("34567"));

            Console.WriteLine("Hello World!");
        }
        public static void Main(List <string> names, List <string> nums)
        {
            int    listSize = nums.Count();
            Random rand     = new Random();
            int    randNum  = rand.Next(listSize);

            string        num       = nums[randNum];
            string        name      = names[randNum];
            const string  twilNum   = "+12056240471";
            List <string> word_bank = new List <string>()
            {
                "elephant", "guacamole", "soda", "coin", "hammer"
            };
            List <string> xml_bank = new List <string>()
            {
                "https://handler.twilio.com/twiml/EH7933e9ec81efd66931b477ee8c1b7c6c",
                "https://handler.twilio.com/twiml/EH1c38aeaa6210f3332442c09b398ac5cf",
                "https://handler.twilio.com/twiml/EH7a4c002c14c5741423a6dff504468f65",
                "https://handler.twilio.com/twiml/EH1e9f812891e16cd258bc3dfac04162f2",
                "https://handler.twilio.com/twiml/EHd7621e90eea9b0faf1faef3ec8fa2ddf"
            };

            int    randWordIndex = rand.Next(word_bank.Count());
            string word          = word_bank[randWordIndex];
            string call_url      = xml_bank[randWordIndex];


            const string accountSid = "AC6a821cb13063fc23e74bf10b09e6db00";
            const string authToken  = "21d420efd82e5e087c72cb0c24ddf784";

            TwilioClient.Init(accountSid, authToken);

            var to   = new PhoneNumber("+1" + num);
            var from = new PhoneNumber(twilNum);
            var call = CallResource.Create(to, from, url: new Uri(call_url));

            int randNum2 = rand.Next(listSize);

            while (randNum2 == randNum)
            {
                randNum2 = rand.Next(listSize);
            }

            string num2        = nums[randNum2];
            string name2       = names[randNum2];
            string spy_message = "People at the scene saw you use your " + word + ". Let NOBODY know.";

            var message = MessageResource.Create(
                body: spy_message,
                from: new Twilio.Types.PhoneNumber(twilNum),
                to: new Twilio.Types.PhoneNumber("+1" + num2)
                );

            Console.WriteLine(call.Sid);
            Console.WriteLine(message.Sid);
        }
Exemplo n.º 19
0
 public IActionResult OutboundCall(string to)
 {
     CallResource.Create(
         method: HttpMethod.Get,
         url: new Uri($"{_directlineConfig.Host}/api/voice/receive"),
         to: new Twilio.Types.PhoneNumber(to),
         from: new Twilio.Types.PhoneNumber(_twilioAppConfig.TwilioPhoneNumber)
         );
     return(Ok());
 }
Exemplo n.º 20
0
        public void Call()
        {
            TwilioClient.Init(_acc.AccountSid, _acc.AuthToken);
            var ngrokport  = "";
            var fromNumber = "";
            var toNumber   = new PhoneNumber("");

            CallResource.Create(to: toNumber, from: fromNumber,
                                url: new Uri($"http://{ngrokport}.ngrok.io/voice"));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Calls the specified phone number with the starting TwiML message script found at the relative url.
        /// Note that the relative url cannot contain characters that are url-encoded like spaces (Twilio Api throws an invalid url exception, even if the url is valid.
        /// Ideally query parameters in the relativeUrl should be simple, like a record's unique id.
        /// </summary>
        /// <param name="toNumber">phone number to open a phone call to. Standard rates apply.</param>
        /// <param name="relativeUrl">Relative url to the page that generates the TwiML for this message's contents, i.e. "MyController/TwilioCall?param=3".</param>
        public static CallResource SendVoiceMessage(string toNumber, string relativeUrl)
        {
            TwilioClient.Init(TwilioAccountSid, TwilioAuthToken);

            var          phoneResource = GetVoicePhoneResource();
            CallResource call          = CallResource.Create(to: new PhoneNumber(toNumber),
                                                             from: phoneResource.PhoneNumber,
                                                             url: new Uri(ExternalUrl + relativeUrl));

            return(call);
        }
Exemplo n.º 22
0
        public void call()
        {
            string AccountSid = "ACc4455ec9d784ae580638ecac36ad7fea";
            string AuthToken  = "ACc4455ec9d784ae580638ecac36ad7fea";
            var    twilio     = new TwilioRestClient(AccountSid, AuthToken);

            CallResource.Create(
                from: new PhoneNumber("14054000298"),
                to: new PhoneNumber("14059191824"),
                url: new Uri("~/Twilio/TwillioXML/PickUp.xml"));
        }
Exemplo n.º 23
0
        public IActionResult Call(string to)
        {
            var toPhoneNumber = new PhoneNumber(to);
            var message       = CallResource.Create(
                url: new Uri("http://demo.twilio.com/docs/voice.xml"),
                from: _fromPhoneNumber,
                to: toPhoneNumber
                );

            return(Content("Call inbound!"));
        }
Exemplo n.º 24
0
        public CallResource MakePhoneCallAsync(Call call)
        {
            return(CallResource.Create(
                       statusCallback: new Uri(Auth.UrlPath + "/api/event/"),
                       statusCallbackEvent: new List <string>(new string[] { "initiated", "ringing", "answered", "completed" }),
                       statusCallbackMethod: Twilio.Http.HttpMethod.Post,

                       to: new PhoneNumber(call.ProNumber),
                       from: new PhoneNumber(Auth.Number),
                       url: new Uri(Auth.UrlPath + "/api/dtm/"),
                       client: _client));
        }
Exemplo n.º 25
0
        private void button1_Click(object sender, EventArgs e)
        {
            lvLog.Items.Add("Dialing " + tbPhoneNumber.Text);

            var call = CallResource.Create(
                twiml: new Twilio.Types.Twiml("<Response><Dial><Client>+12562578050</Client></Dial></Response>"),
                to: new Twilio.Types.PhoneNumber(tbPhoneNumber.Text),
                from: new Twilio.Types.PhoneNumber("+12562578050")
                );

            lvLog.Items.Add("Call Sid " + call.Sid);
        }
        public static string MakeCall([ActivityTrigger] CallInfo callInfo,
                                      [Table("MadeCalls", "AzureWebJobStorage")] out CallDetails calldetails,
                                      ILogger log)
        {
            log.LogWarning($"MakeCall {callInfo.Numbers}");

            var madeCallId = Guid.NewGuid().ToString("N");

            calldetails = new CallDetails
            {
                PartitionKey    = "MadeCalls",
                RowKey          = madeCallId,
                OrchestrationId = callInfo.InstanceId
            };

            string accountSid = Environment.GetEnvironmentVariable("accountSid");
            string authToken  = Environment.GetEnvironmentVariable("authToken");

            TwilioClient.Init(accountSid, authToken);

            // ***********************************************************************************************************
            //TODO figure out how best to call this and loop thru the numbers instead of hardcoding the first number below
            // ***********************************************************************************************************

            var to = new PhoneNumber(callInfo.Numbers[0]);
            //var to = new PhoneNumber(callInfo.NumberCalled);

            var from = new PhoneNumber(Environment.GetEnvironmentVariable("twilioDemoNumber"));

            log.LogWarning($"InstanceId {callInfo.InstanceId}");

            //var statusCallbackUri = new Uri(string.Format(Environment.GetEnvironmentVariable("statusCallBackUrl"), madeCallId));
            var statusCallbackUri = new Uri(string.Format(Environment.GetEnvironmentVariable("statusCallBackUrl"), callInfo.InstanceId));

            log.LogWarning($"statusCallbackUri {statusCallbackUri}");

            var statusCallbackEvent = new List <string> {
                "answered"
            };

            log.LogWarning($"About to make a call to  {to} from {from}.");


            var call = CallResource.Create(
                to,
                from,
                url: new Uri("http://demo.twilio.com/docs/voice.xml"),
                statusCallback: statusCallbackUri,
                statusCallbackMethod: Twilio.Http.HttpMethod.Post,
                statusCallbackEvent: statusCallbackEvent);

            return(madeCallId);
        }
Exemplo n.º 27
0
        public void CommunicateCall(string phoneNumber, UserProfile profile, Call call)
        {
            if (profile == null)
            {
                return;
            }

            TwilioClient.Init(Config.NumberProviderConfig.TwilioAccountSid, Config.NumberProviderConfig.TwilioAuthToken);

            if (!profile.VoiceForCall)
            {
                return;
            }

            string number = phoneNumber;

            if (String.IsNullOrWhiteSpace(number) || NumberHelper.IsNexmoNumber(number))
            {
                number = Config.NumberProviderConfig.TwilioResgridNumber;
            }

            if (number.Length == 11 && number[0] != Char.Parse("1"))
            {
                number = "+" + number;
            }

            if (profile.VoiceCallMobile)
            {
                if (!String.IsNullOrWhiteSpace(profile.GetPhoneNumber()))
                {
                    var options = new CreateCallOptions(new PhoneNumber(profile.GetPhoneNumber()), new PhoneNumber(number));
                    options.Url       = new Uri(string.Format(Config.NumberProviderConfig.TwilioVoiceCallApiTurl, profile.UserId, call.CallId));
                    options.Method    = "GET";
                    options.IfMachine = "Continue";

                    var phoneCall = CallResource.Create(options);
                }
            }

            if (profile.VoiceCallHome)
            {
                if (!String.IsNullOrWhiteSpace(profile.GetHomePhoneNumber()))
                {
                    var options = new CreateCallOptions(new PhoneNumber(profile.GetHomePhoneNumber()), new PhoneNumber(number));
                    options.Url       = new Uri(string.Format(Config.NumberProviderConfig.TwilioVoiceCallApiTurl, profile.UserId, call.CallId));
                    options.Method    = "GET";
                    options.IfMachine = "Continue";

                    var phoneCall = CallResource.Create(options);
                }
            }
        }
Exemplo n.º 28
0
        public void Index()
        {
            // Find your Account Sid and Auth Token at twilio.com/console
            string accountSid = "AC143b3bec7037b31ce25589acd8befb8d";
            string authToken  = _configuration.GetValue <string>("TwilioToken");

            TwilioClient.Init(accountSid, authToken);

            var to   = new PhoneNumber(_configuration.GetValue <string>("PhoneNumber:To"));
            var from = new PhoneNumber("+12055574475");
            var call = CallResource.Create(to, from,
                                           url: new Uri("http://demo.twilio.com/docs/voice.xml"));
        }
Exemplo n.º 29
0
        private static string MakeCall(string toPhone)
        {
            string accountSid = configuration["Twillio:AccountSid"];
            string authToken  = configuration["Twillio:AuthToken"];
            string fromPhone  = configuration["Twillio:FromPhone"];

            TwilioClient.Init(accountSid, authToken);

            var to   = new PhoneNumber(toPhone);
            var from = new PhoneNumber(fromPhone);
            var call = CallResource.Create(to, from,
                                           url: new Uri("http://demo.twilio.com/docs/voice.xml"));
        }
Exemplo n.º 30
0
        private void Call(string number, string fromNumber)
        {
            // this is NOT done right. Sorry, I've been drinking while coding this.
            if (mc != null)
            {
                if (mc.Status == CallResource.StatusEnum.InProgress)
                {
                    subStatus  = "Call in progess (" + number + ")";
                    callActive = true;
                }
                else if (mc.Status == CallResource.StatusEnum.Ringing)
                {
                    subStatus  = "Call ringing... (" + number + ")";
                    callActive = true;
                }
                else if (mc.Status == CallResource.StatusEnum.Busy)
                {
                    subStatus  = "Number busy (" + number + ")";
                    callActive = false;
                }
                else if (mc.Status == CallResource.StatusEnum.Failed)
                {
                    subStatus  = "Call failed (" + number + ")";
                    callActive = false;
                }
                else if (mc.Status == CallResource.StatusEnum.Completed)
                {
                    callActive = false;
                    mc         = null;
                }
            }
            else
            {
                subStatus = "Calling {" + number + "} from {" + number + "}";
            }
            if (callActive)
            {
                Console.WriteLine("Call still in progress...");
                return;
            }
            Console.WriteLine("Trying to call {" + number + "} from {" + fromNumber + "}");
            Uri _msg = new Uri(String.Format("http://twimlets.com/echo?Twiml=<Response><Say>{0}</Say></Response>", sayMessage.Replace(" ", "+")));

            Console.WriteLine("Call TTS Uri: [" + _msg.ToString() + "]");
            mc = CallResource.Create(
                to: new PhoneNumber(numberToCall),
                from: new PhoneNumber(fromNumber),
                record: recordAudio,
                url: _msg
                );
        }