Exemple #1
0
 private static async Task MainAsync()
 {
     var calloutApi = SinchFactory.CreateApiFactory("f429b49c-4ca8-4b9a-9376-3c22428c5309", "ui8/g2EMaEieaPA5/1L+fQ==").CreateCalloutApi();
     var calloutResponse = await calloutApi.TTSCallout("+15612600684", "how are you doing", "").Call();
     
     Console.WriteLine(calloutResponse.callId);
     Console.ReadLine();
 }
Exemple #2
0
        private static async Task MainAsync()
        {
            var calloutApi      = SinchFactory.CreateApiFactory("00000000-0000-0000-0000-000000000000", "AAAAAAAAAAAAAAAAAAAAAA==").CreateCalloutApi();
            var calloutResponse = await calloutApi.TTSCallout("+15612600684", "How are you doing?", "").Call();

            Console.WriteLine(calloutResponse.callId);
            Console.ReadLine();
        }
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            var factory = SinchFactory.CreateApiFactory("00000000-0000-0000-0000-000000000000", "AAAAAAAAAAAAAAAAAAAAAA==");

            GlobalConfiguration.Configuration.MessageHandlers.Add(new CallbackMessageHandler(factory));
        }
Exemple #4
0
        private IConference Getconference(string conferenceId)
        {
            // 1. Create an api factory
            var sinch = SinchFactory.CreateApiFactory(yourkey, yoursecret);
            // 2. Get a ConferenceApi client
            var conferenceClient = sinch.CreateConferenceApi();

            //fetch the conference
            return(conferenceClient.Conference(conferenceId));
        }
Exemple #5
0
        private static async Task MainAsync()
        {
            var smsApi          = SinchFactory.CreateApiFactory("00000000-0000-0000-0000-000000000000", "AAAAAAAAAAAAAAAAAAAAAA==").CreateSmsApi();
            var sendSmsResponse = await smsApi.Sms("+61491570156", "Hello world.  Sinch SMS here.").Send();

            await Task.Delay(TimeSpan.FromSeconds(10)); // May take a second or two to be delivered.

            var smsMessageStatusResponse = await smsApi.GetSmsStatus(sendSmsResponse.MessageId);

            Console.WriteLine(smsMessageStatusResponse.Status);
            Console.ReadLine();
        }
Exemple #6
0
        private static async Task MainAsync()
        {
            var          calloutApi  = SinchFactory.CreateApiFactory("f429b49c-4ca8-4b9a-9376-3c22428c5309", "ui8/g2EMaEieaPA5/1L+fQ==").CreateCalloutApi();
            IMenuBuilder menuBuilder = calloutApi.CreateMenuBuilder();

            menuBuilder.AddNumberInputMenu("main", "This is a test call from Azure MFA. Please enter the following digits: 1 7 8 9. Press 'pound' if the digits were unclear.", 4,
                                           "This is a test call from Azure MFA. Please enter the following digits: 1 7 8 9. Press 'pound' if the digits were unclear.", 1, TimeSpan.FromSeconds(15));
            //var calloutResponse = await calloutApi.MenuCallout("+15612600684", "how are you doing", menuBuilder,  "main", TimeSpan.FromSeconds(25),"www1545654").Call();
            var calloutResponse = await calloutApi.ConferenceCallout("+17207072699", "asdfsadfsdf", "11111", "hi command", "ww951197111#").Call();

            Console.WriteLine(calloutResponse.callId);
            Console.ReadLine();
        }
Exemple #7
0
        private static async Task MainAsync()
        {
            var calloutApi = SinchFactory.CreateApiFactory("00000000-0000-0000-0000-000000000000", "AAAAAAAAAAAAAAAAAAAAAA==").CreateCalloutApi();

            // TTS callout
            var calloutResponse = await calloutApi.TtsCallout("+15612600684", "How are you doing?", "").Call();

            Console.WriteLine(calloutResponse.callId);
            Console.ReadLine();

            // Conference callout
            calloutResponse = await calloutApi.ConferenceCallout(To.Username("Buddy"), "ConfId-123", "", "Welcome!").Call();

            Console.WriteLine(calloutResponse.callId);
            Console.ReadLine();

            // Menu callout
            var menu = calloutApi.CreateMenuBuilder()
                       .BeginMenuDefinition("main", new PromptFile("press1forinput_press2forexit"), null)
                       .AddGotoMenuOption(Dtmf.Digit1, "input")
                       .AddTriggerPieOption(Dtmf.Digit2, "exit")
                       .EndMenuDefinition()
                       .AddNumberInputMenu("input", new PromptFile("enterprompt"), 4);


            calloutResponse = await calloutApi
                              .MenuCallout("+15612600684", "+15612600684", menu, "main", TimeSpan.FromSeconds(5)).Call();

            Console.WriteLine(calloutResponse.callId);
            Console.ReadLine();

            // Custom callout with ICE and ACE handlers
            var crf = SinchFactory.CreateCallbackResponseFactory(Locale.EnUs);

            var ice = crf.CreateIceSvamletBuilder()
                      .ConnectPstn("+15612600684")
                      .WithAnonymousCli()
                      .WithDialTimeout(TimeSpan.FromSeconds(30));

            var ace = crf.CreateAceSvamletBuilder()
                      .Say("Hello there!")
                      .Build();

            calloutResponse = await calloutApi.CustomCallout(ice.Body, ace.Body, null, null).Call();

            Console.WriteLine(calloutResponse.callId);
            Console.ReadLine();
        }
        public async Task SendSMS(Message message, Subscriber to)
        {
            var smsApi    = SinchFactory.CreateApiFactory(_sinchConfig.Key, _sinchConfig.Secret).CreateSmsApi();
            var messageid = await smsApi.Sms(to.Number,
                                             message.MessageContent + "\n\n" +
                                             _sinchConfig.MarketingFooter)
                            .WithCli(_sinchConfig.SinchNumber).Send();

            _context.SendLogs.Add(new SendLog()
            {
                DateSent       = DateTime.UtcNow,
                MessageId      = message.MessageId,
                SubscriberId   = to.SubscriberId,
                SinchMessageId = messageid.MessageId.ToString()
            });
            await _context.SaveChangesAsync();
        }
        static async Task <IEnumerable <User> > getUsers()
        {
            string   path       = "http://localhost:56362/api/users/couponlist";
            ObjectId userId     = new ObjectId();
            string   phoneNum   = "";
            string   smsMessage = "";
            string   code       = "";

            //await Task.Delay(3000);

            var response = await client.GetAsync(path);

            response.EnsureSuccessStatusCode();
            var stringResult = await response.Content.ReadAsStringAsync();

            IEnumerable <User> users = JsonConvert.DeserializeObject <IEnumerable <User> >(stringResult);

            // process messages
            foreach (User u in users)
            {
                userId     = u.userId;
                phoneNum   = u.userPhone;
                code       = u.code.ToString();
                smsMessage = u.message + " Please use code: " + code + " when you order.";
                var smsApi          = SinchFactory.CreateApiFactory("86be6998-e82f-49eb-9d8d-cdd2427ad4a9", "5MnvbXXhe0iMuzXjl02WWQ==").CreateSmsApi();
                var sendSmsResponse = await smsApi.Sms("+19094524127", smsMessage).Send();

                await Task.Delay(TimeSpan.FromSeconds(10));

                var smsMessageStatusResponse = await smsApi.GetSmsStatus(sendSmsResponse.MessageId);

                if (smsMessageStatusResponse.Status == "successful")
                {
                    // update db
                }
            }



            return(users);
        }
        private static async Task MainAsync()
        {
            var calloutApi = SinchFactory.CreateApiFactory("00000000-0000-0000-0000-000000000000", "AAAAAAAAAAAAAAAAAAAAAA==").CreateCalloutApi();

            // TTS callout
            var calloutResponse = await calloutApi.TtsCallout("+15612600684", "How are you doing?", "").Call();

            Console.WriteLine(calloutResponse.callId);
            Console.ReadLine();

            // Menu callout
            var menu = calloutApi.CreateMenuBuilder()
                       .BeginMenuDefinition("main", new PromptFile("press1forinput_press2forexit"), null)
                       .AddGotoMenuOption(Dtmf.Digit1, "input")
                       .AddTriggerPieOption(Dtmf.Digit2, "exit")
                       .EndMenuDefinition()
                       .AddNumberInputMenu("input", new PromptFile("enterprompt"), 4);


            calloutResponse = await calloutApi.MenuCallout("+15612600684", "+15612600684", menu, "main", TimeSpan.FromSeconds(5)).Call();

            Console.WriteLine(calloutResponse.callId);
            Console.ReadLine();
        }
        private static async Task MainAsync()
        {
            try
            {
                var api = SinchFactory.CreateApiFactory("00000000-0000-0000-0000-000000000000", "AAAAAAAAAAAAAAAAAAAAAA==").CreateVerificationApi();

                var number    = "+61491570156";
                var reference = Guid.NewGuid().ToString();
                var custom    = Guid.NewGuid().ToString();

                // you must supply a number when initiating and reporting a verification
                var initiate = await api.Verification(number).WithReference(reference).WithCustom(custom).Initiate(VerificationMethod.FlashCall);

                Console.WriteLine($"Id: {initiate.Id}, Cli: {initiate.FlashCall.CliFilter}");

                // for a flashCall or callout verification the Cli is required. For sms its optional but the Code is required
                var report = await api.Verification(number).WithCli(initiate.FlashCall.CliFilter).Report(VerificationMethod.FlashCall);

                Console.WriteLine($"Status: {report.Status}, Reason: {report.Reason}");

                // you can get the result of a verification in the following ways:
                await api.Verification().WithId(initiate.Id).Get();

                await api.Verification().WithReference(reference).Get();

                var result = await api.Verification(number).Get();

                Console.WriteLine($"Status: {result.Status}, Reason: {result.Reason}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            Console.ReadLine();
        }