示例#1
0
    public static void Main(string[] args)
    {
        var client = new CallfireClient("api_login", "api_password");

        var request = new SendCallsRequest()
        {
            DefaultVoice = Voice.MALE1,
            Fields       = "items(id,state,toNumber)",
            CampaignId   = 4050600003,
            Recipients   = new List <CallRecipient>
            {
                new CallRecipient
                {
                    PhoneNumber    = "12135551100",
                    LiveMessage    = "Hello, Alice, this is message for live answer",
                    MachineMessage = "Hello, Alice, this is message for answering machine"
                },
                new CallRecipient
                {
                    PhoneNumber    = "12135551101",
                    LiveMessage    = "Hello, Bob, this is message for live answer",
                    MachineMessage = "Hello, Bob, this is message for answering machine"
                }
            }
        };

        IList <Call> calls = client.CallsApi.Send(request);
    }
    public static void Main(string[] args)
    {
        var client = new CallfireClient("api_login", "api_password");

        var request = new SendCallsRequest()
        {
            Recipients = new List <CallRecipient>
            {
                new CallRecipient
                {
                    PhoneNumber    = "12135551100",
                    LiveMessage    = "Hello, Alice, this is message for live answer",
                    MachineMessage = "Hello, Alice, this is message for answering machine"
                },
                new CallRecipient
                {
                    PhoneNumber    = "12135551101",
                    LiveMessage    = "Hello, Bob, this is message for live answer",
                    MachineMessage = "Hello, Bob, this is message for answering machine"
                }
            }
        };

        IList <Call> calls = client.CallsApi.Send(request);
    }
        /// <summary>
        /// Send calls to recipients through default campaign.
        /// Use the API to quickly send individual calls.
        /// A verified Caller ID and sufficient credits are required to make a call.
        /// </summary>
        /// <param name="request">request object with different fields to filter</param>
        /// <returns>list with created call objects</returns>
        /// <exception cref="BadRequestException">          in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception>
        /// <exception cref="UnauthorizedException">        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception>
        /// <exception cref="AccessForbiddenException">     in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception>
        /// <exception cref="ResourceNotFoundException">    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception>
        /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception>
        /// <exception cref="CallfireApiException">         in case HTTP response code is something different from codes listed above.</exception>
        /// <exception cref="CallfireClientException">      in case error has occurred in client.</exception>
        public IList <Call> Send(SendCallsRequest request)
        {
            Validate.NotBlank(request.Recipients.ToString(), "recipients cannot be blank");
            var queryParams = ClientUtils.BuildQueryParams(request);

            return(Client.Post <ListHolder <Call> >(CALLS_PATH, request.Recipients, queryParams).Items);
        }
    public static void Main(string[] args)
    {
        var client = new CallfireClient("api_login", "api_password");

        var request = new SendCallsRequest()
        {
            Recipients = new List <CallRecipient> {
                new CallRecipient {
                    PhoneNumber = "12135551100",
                    Attributes  = new Dictionary <string, string> {
                        { "external_user_id", "45450007002" }
                    },
                    DialplanXml = @"
                        <dialplan name=""Root"">
                            <menu maxDigits=""1"" timeout=""3500"" name=""Live"">
                                <play type=""tts"" voice=""female1"">
                                    Hello, this is UMM Health Center, you have an appointment with Dr. Andrew
                                    tomorrow at 3:00 PM, please press 1 to confirm the time or press 2 to reschedule
                                    appointment.
                                </play>
                                <keypress pressed=""1"">
                                     <!-- user pressed 1, store this data in 'selected_menu' variable -->
                                    <stash varname=""selected_menu"">confirmed</stash>
                                    <goto>bye_tts</goto>
                                </keypress>
                                <keypress pressed=""2"">
                                     <!-- user pressed 2, store this data in 'selected_menu' variable -->
                                    <stash varname=""selected_menu"">reschedule</stash>
                                    <play type=""tts"" voice=""female1"">
                                        You will be transferred to our representative to reschedule an appointment. Please wait.
                                    </play>
                                    <transfer callerid=""${call.callerid}"" musiconhold=""blues"" mode=""ringall"">
                                        15550005500
                                    </transfer>
                                </keypress>
                                 <!-- if pressed key is not specified in menu replay Live menu -->
                                <keypress pressed=""default"" name=""incorrect_Selection"">
                                    <play type=""tts"" voice=""female1"">That is not a valid selection. Please try again.</play>
                                    <goto name=""replay_Live"">Live</goto>
                                </keypress>
                            </menu>
                            <play type=""tts"" voice=""female1"" name=""bye_tts"">
                                Thank you for your response. Have a good day.
                            </play>
                            <hangup name=""Hangup""/>
                        </dialplan>
                    "
                }
            }
        };

        IList <Call> calls = client.CallsApi.Send(request);
    }
示例#5
0
        public void SendCall()
        {
            var contacts = Client.ContactsApi.Find(new FindContactsRequest());

            var recipient1 = new CallRecipient {
                ContactId = contacts.Items[0].Id, LiveMessage = "testMessage", TransferDigit = "1", TransferMessage = "transferTestMessage"
            };
            var recipient2 = new CallRecipient {
                ContactId = contacts.Items[0].Id, LiveMessage = "testMessage", TransferDigit = "1", TransferMessageSoundId = 9643523003
            };
            var recipients = new List <CallRecipient> {
                recipient1, recipient2
            };

            IList <Call> calls = Client.CallsApi.Send(recipients, null, "items(id,fromNumber,state)");

            Console.WriteLine("Calls: " + calls);

            Assert.AreEqual(2, calls.Count);
            Assert.NotNull(calls[0].Id);
            Assert.IsNull(calls[0].CampaignId);
            Assert.AreEqual(StateType.READY, calls[0].State);

            var request = new SendCallsRequest
            {
                Recipients            = recipients,
                CampaignId            = 7373471003,
                Fields                = "items(id, fromNumber, state, campaignId)",
                DefaultLiveMessage    = "DefaultLiveMessage",
                DefaultMachineMessage = "DefaultMachineMessage",
                DefaultVoice          = Voice.FRENCHCANADIAN1,
                StrictValidation      = true
            };

            calls = Client.CallsApi.Send(request);
            Assert.AreEqual(2, calls.Count);
            Assert.AreEqual(calls[0].CampaignId, 7373471003);

            request = new SendCallsRequest
            {
                Recipients = recipients,
                CampaignId = 7373471003,
                Fields     = "items(id, fromNumber, state, campaignId)",
                DefaultLiveMessageSoundId    = 9643523003,
                DefaultMachineMessageSoundId = 9643523003,
                DefaultVoice = Voice.FRENCHCANADIAN1
            };
            calls = Client.CallsApi.Send(request);
            Assert.AreEqual(2, calls.Count);
        }
        public void SendCallsUsingRequest()
        {
            string requestJson  = GetJsonPayload("/callstexts/callsApi/request/sendCalls.json");
            string responseJson = GetJsonPayload("/callstexts/callsApi/response/sendCalls.json");
            var    restRequest  = MockRestResponse(responseJson);

            CallRecipient r1 = new CallRecipient {
                PhoneNumber = "12135551100", LiveMessage = "Why hello there!", TransferDigit = "1", TransferMessage = "testMessage", TransferNumber = "12135551101"
            };
            CallRecipient r2 = new CallRecipient {
                PhoneNumber = "12135551101", LiveMessage = "And hello to you too.", FromNumber = "12135551102"
            };

            var request = new SendCallsRequest
            {
                Recipients = new List <CallRecipient> {
                    r1, r2
                },
                CampaignId                   = 10,
                Fields                       = FIELDS,
                DefaultLiveMessage           = "DefaultLiveMessage",
                DefaultMachineMessage        = "DefaultMachineMessage",
                DefaultLiveMessageSoundId    = 1,
                DefaultMachineMessageSoundId = 1,
                DefaultVoice                 = Voice.FRENCHCANADIAN1,
                StrictValidation             = true
            };

            IList <Call> calls = Client.CallsApi.Send(request);

            Assert.That(Serializer.Serialize(new ListHolder <Call>(calls)), Is.EqualTo(responseJson));
            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);

            Assert.That(Serializer.Serialize(requestBodyParam.Value), Is.EqualTo(requestJson));

            calls = Client.CallsApi.Send(new List <CallRecipient> {
                r1, r2
            }, 10, FIELDS);
            Assert.That(restRequest.Value.Resource, !Does.Contain("fields" + FIELDS));
            Assert.That(restRequest.Value.Resource, !Does.Contain("campaignId=10"));
            Assert.That(restRequest.Value.Resource, !Does.Contain("defaultLiveMessage=DefaultLiveMessage"));
            Assert.That(restRequest.Value.Resource, !Does.Contain("defaultMachineMessage=DefaultMachineMessage"));
            Assert.That(restRequest.Value.Resource, !Does.Contain("defaultLiveMessageSoundId=1"));
            Assert.That(restRequest.Value.Resource, !Does.Contain("defaultMachineMessageSoundId=1"));
            Assert.That(restRequest.Value.Resource, !Does.Contain("defaultMachineMessageSoundId=1"));
            Assert.That(restRequest.Value.Resource, !Does.Contain("defaultVoice=FRENCHCANADIAN1"));
            Assert.That(restRequest.Value.Resource, !Does.Contain("strictValidation=TRUE"));
        }
示例#7
0
    public static void Main(string[] args)
    {
        var client = new CallfireClient("api_login", "api_password");

        var request = new SendCallsRequest()
        {
            Recipients = new List <CallRecipient> {
                new CallRecipient {
                    PhoneNumber = "12135551100",
                    Attributes  = new Dictionary <string, string> {
                        { "external_user_id", "45450007002" }
                    },
                    DialplanXml = @"
                          <dialplan name=""Root"">
                              <!-- answering machine detection -->
                              <amd>
                                  <!-- if call is answered by human go to live menu -->
                                  <live>
                                      <goto>live</goto>
                                  </live>
                                  <!-- hangup if answering machine detected -->
                                  <machine>
                                      <goto>hangup</goto>
                                  </machine>
                              </amd>
                              <menu maxDigits=""1"" timeout=""3500"" name=""live"">
                                  <!-- play text message with secure code -->
                                  <play type=""tts"" voice=""female1"" name=""play_code"">Hello, your one-time code is 2 5 1 7, press 1 to repeat.</play>
                                  <keypress pressed=""1"">
                                      <goto>live</goto>
                                  </keypress>
                                  <keypress pressed=""timeout"">
                                      <hangup/>
                                  </keypress>
                              </menu>
                              <hangup name=""hangup""/>
                          </dialplan>
                      "
                }
            }
        };

        IList <Call> calls = client.CallsApi.Send(request);
    }