示例#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();
 }
示例#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));
        }
示例#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));
        }
示例#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();
        }
示例#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();
        }
示例#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();
        }
示例#9
0
        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);
        }
        public async Task <SvamletModel> Post(CallbackEventModel model)
        {
            var sinch   = SinchFactory.CreateCallbackResponseFactory(Locale.EnUs);
            var reader  = sinch.CreateEventReader();
            var evt     = reader.ReadModel(model);
            var builder = sinch.CreateIceSvamletBuilder();

            switch (evt.Event)
            {
            case Event.IncomingCall:
                builder.AddNumberInputMenu("menu1", "Enter 4 digits", 4, "Enter 4 digits", 3, TimeSpan.FromSeconds(60));
                builder.RunMenu("menu1");
                break;

            case Event.PromptInput:
                using (var db = new ConferenceContext()) {
                    var conference = db.Conferences.FirstOrDefault(c => c.PinCode == model.MenuResult.Value);
                    if (conference != null)
                    {
                        builder.ConnectConference(conference.ConferenceId.ToString());
                    }
                    else
                    {
                        builder.Say("Invalid code").Hangup(HangupCause.Normal);
                    }
                }

                break;

            case Event.AnsweredCall:
                builder.Continue();
                break;

            default:
                break;
            }
            return(builder.Build().Model);
        }
示例#11
0
        static void Main(string[] args)
        {
            var iceRequestText = File.ReadAllText("../../ice.txt");

            var sinch = SinchFactory.CreateCallbackResponseFactory(Locale.EnUs);

            var evt = sinch.CreateEventReader().ReadJson(iceRequestText);

            if (evt is IIceEvent)
            {
                var iceEvent = evt as IIceEvent;
                Console.WriteLine("Ice Event");
                Console.WriteLine("From: " + iceEvent.Cli);
                Console.WriteLine("To: " + iceEvent.To.Endpoint);

                var menu = sinch.CreateMenuBuilder();
                menu.AddNumberInputMenu("ipt", new TtsPrompt("Hello!"), 4);

                var response        = sinch.CreateIceSvamletBuilder();
                var iceResponseText = response.RunMenu("ipt", menu).Body;

                Console.WriteLine(iceResponseText);

                iceResponseText =
                    response
                    .Say("Hello world")
                    .Say("Will connect your call")
                    .SetCookie("mycookie", "myvalue")
                    .ConnectPstn("+46777888999")
                    .WithBridgeTimeout(TimeSpan.FromMinutes(2.5))
                    .WithAnonymousCli()
                    .WithCallTag(CallTag.DefaultBillingTag, "C02-14")
                    .WithCallTag("CustomCallTag", "foo")
                    .WithAnsweringMachineDetection().Body;

                Console.WriteLine(iceResponseText);
            }
        }
示例#12
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();

            // 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();
        }
示例#13
0
        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();
        }