public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var broadcast = new CallBroadcast { Name = "Example API Call Broadcast", // set validated Caller ID number. FromNumber = "12135551189", // set answering machine detection AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, // set voice messages using TTS option for Live answers and when Answering Machine is detected. // you also can set a pre-defined TTS voice. Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", MachineSoundText = "This is an answering machine text to speech recording" }, // add new recipients Recipients = new List <Recipient> { new Recipient { PhoneNumber = "2134441133" }, new Recipient { PhoneNumber = "2135551144" } }, ResumeNextDay = true }; // create broadcast with 'start' argument = true to start campaign immediately var id = client.CallBroadcastsApi.Create(broadcast); }
public void CreateIvrBroadcast() { var requestJson = GetJsonPayload("/campaigns/callBroadcastsApi/request/createIvrBroadcast.json"); var responseJson = GetJsonPayload("/campaigns/callBroadcastsApi/response/createIvrBroadcast.json"); var restRequest = MockRestResponse(responseJson); var callBroadcast = new CallBroadcast { Name = "Example API IVR", FromNumber = "12135551189", DialplanXml = "<dialplan name=\"Root\"></dialplan>", Recipients = new List <Recipient> { new Recipient { PhoneNumber = "13233832214" }, new Recipient { PhoneNumber = "13233832215" }, } }; var id = Client.CallBroadcastsApi.Create(callBroadcast, true); Assert.That(Serializer.Serialize(id), Is.EqualTo(responseJson)); Assert.AreEqual(Method.POST, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson)); Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("start") && p.Value.Equals("True"))); }
public void IvrsCrudOperations() { var broadcast = new CallBroadcast { Name = "ivr_broadcast1", DialplanXml = "<dialplan name=\"Root\"></dialplan>", Recipients = new List <CallRecipient> { new CallRecipient { PhoneNumber = "12132212384" }, new CallRecipient { PhoneNumber = "12132212385" } } }; var id = Client.CallBroadcastsApi.Create(broadcast, true); System.Console.WriteLine("ivr id: " + id); var savedBroadcast = Client.CallBroadcastsApi.Get(id.Id); Assert.AreEqual(broadcast.Name, savedBroadcast.Name); savedBroadcast.Name = "updated_name"; savedBroadcast.DialplanXml = "<dialplan name=\"Root\">\r\n\t<play type=\"tts\">Congratulations! You have successfully configured a CallFire I V R.</play>\r\n</dialplan>"; Client.CallBroadcastsApi.Update(savedBroadcast, true); var updatedBroadcast = Client.CallBroadcastsApi.Get(id.Id, "id,name"); Assert.Null(updatedBroadcast.Status); Assert.NotNull(updatedBroadcast.Id); Assert.AreEqual(savedBroadcast.Name, updatedBroadcast.Name); }
/// <summary> /// Update broadcast /// </summary> /// <param name="broadcast">broadcast to update</param> /// <param name="strictValidation">apply strict validation for contacts</param> /// <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 void Update(CallBroadcast broadcast, bool?strictValidation = null) { Validate.NotNull(broadcast.Id, "broadcast.id cannot be null"); var queryParams = ClientUtils.BuildQueryParams("strictValidation", strictValidation.ToString()); Client.Put <object>(CB_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, broadcast.Id.ToString()), broadcast, queryParams); }
public void UpdateVoiceBroadcast() { var expectedJson = GetJsonPayload("/campaigns/callBroadcastsApi/request/updateCallBroadcast.json"); var restRequest = MockRestResponse(expectedJson); var callBroadcast = new CallBroadcast { Id = 11, Name = "Example API VB updated", FromNumber = "12135551189", AnsweringMachineConfig = AnsweringMachineConfig.LIVE_IMMEDIATE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is an updated VB config tts", MachineSoundId = 1258704003 }, ResumeNextDay = true }; Client.CallBroadcastsApi.Update(callBroadcast); Assert.AreEqual(Method.PUT, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.AreEqual(requestBodyParam.Value, expectedJson); Assert.That(restRequest.Value.Resource, Is.StringEnding("/11")); }
/// <summary> /// Create a call broadcast campaign using the Call Broadcast API. A campaign can be created with /// no contacts and bare minimum configuration, but contacts will have to be added further on to use the campaign. /// If start set to true campaign starts immediately /// </summary> /// <param name="broadcast">call broadcast to create</param> /// <param name="start">if set to true then broadcast will start immediately, by default it set to false</param> /// <param name="strictValidation">apply strict validation for contacts</param> /// <returns>ResourceId object with id of created broadcast</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 ResourceId Create(CallBroadcast broadcast, bool start = false, bool?strictValidation = null) { var queryParams = new List <KeyValuePair <string, object> >(2); ClientUtils.AddQueryParamIfSet("start", start.ToString(), queryParams); ClientUtils.AddQueryParamIfSet("strictValidation", strictValidation.ToString(), queryParams); return(Client.Post <ResourceId>(CB_PATH, broadcast, queryParams)); }
public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var broadcast = new CallBroadcast { Id = 11646003, Schedules = new List <Schedule> { // schedule a campaign to run on Saturday and Sunday between 2016-12-01 10:00:00 // and 2016-12-10 18:00:00 new Schedule { StartDate = new LocalDate { Year = 2016, Month = 12, Day = 1 }, StartTimeOfDay = new LocalTime { Hour = 10, Minute = 0, Second = 0 }, StopDate = new LocalDate { Year = 2016, Month = 12, Day = 10 }, StopTimeOfDay = new LocalTime { Hour = 18, Minute = 0, Second = 0 }, // set weekly schedule DaysOfWeek = new HashSet <DayOfWeek> { DayOfWeek.SATURDAY, DayOfWeek.SUNDAY }, // set optional time zone, if leave empty account's timezone will be used TimeZone = "America/New_York" }, // add another schedule for campaign to start on Saturday and Sunday between 2016-12-20 10:00:00 // and 2016-12-30 18:00:00 new Schedule { StartDate = new LocalDate { Year = 2016, Month = 12, Day = 20 }, StartTimeOfDay = new LocalTime { Hour = 10, Minute = 0, Second = 0 }, StopDate = new LocalDate { Year = 2016, Month = 12, Day = 30 }, StopTimeOfDay = new LocalTime { Hour = 18, Minute = 0, Second = 0 }, // set weekly schedule DaysOfWeek = new HashSet <DayOfWeek> { DayOfWeek.SATURDAY, DayOfWeek.SUNDAY } } } }; // update broadcast with new schedules client.CallBroadcastsApi.Update(broadcast); }
public void VoiceBroadcastCrudOperations() { var broadcast = new CallBroadcast { Name = "call_broadcast1", AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", LiveSoundTextVoice = Voice.MALE1, MachineSoundText = "This is an answering machine text to speech recording", MachineSoundTextVoice = Voice.MALE1 }, Recipients = new List <CallRecipient> { new CallRecipient { PhoneNumber = "12132212384" }, new CallRecipient { PhoneNumber = "12132212385" } }, ResumeNextDay = true }; var id = Client.CallBroadcastsApi.Create(broadcast, true, true); System.Console.WriteLine("broadcast id: " + id); var savedBroadcast = Client.CallBroadcastsApi.Get(id.Id); Assert.AreEqual(broadcast.Name, savedBroadcast.Name); Assert.AreEqual(savedBroadcast.ResumeNextDay, true); savedBroadcast.Name = "updated_name"; savedBroadcast.Sounds.LiveSoundText = null; savedBroadcast.Sounds.MachineSoundText = null; savedBroadcast.ResumeNextDay = false; Client.CallBroadcastsApi.Update(savedBroadcast); var updatedBroadcast = Client.CallBroadcastsApi.Get(id.Id, "id,name,resumeNextDay"); Assert.Null(updatedBroadcast.Status); Assert.NotNull(updatedBroadcast.Id); Assert.AreEqual(savedBroadcast.Name, updatedBroadcast.Name); Assert.AreEqual(updatedBroadcast.ResumeNextDay, false); }
public void GetBroadcastCalls() { var broadcast = new CallBroadcast { Name = "call_broadcast", AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", LiveSoundTextVoice = Voice.MALE1, MachineSoundText = "This is an answering machine text to speech recording", MachineSoundTextVoice = Voice.MALE1 }, Recipients = new List <CallRecipient> { new CallRecipient { PhoneNumber = "12132041238" }, new CallRecipient { PhoneNumber = "14246525473" } } }; var id = Client.CallBroadcastsApi.Create(broadcast, false); var getCallsRequest = new GetByIdRequest { Id = id.Id }; var calls = Client.CallBroadcastsApi.GetCalls(getCallsRequest); System.Console.WriteLine(calls); Assert.That(calls.Items, Is.Not.Empty); long testBatchId = (long)calls.Items[0].BatchId; var getCallsRequestNew = new GetBroadcastCallsTextsRequest { Id = id.Id, BatchId = testBatchId }; calls = Client.CallBroadcastsApi.GetCalls(getCallsRequestNew); System.Console.WriteLine(calls); Assert.AreEqual(calls.Items[0].BatchId, testBatchId); }
public void StartStopArchiveCampaign() { CallBroadcast campaign = Client.CallBroadcastsApi.Get(8729046003); Console.WriteLine(campaign); Assert.NotNull(campaign); // start Client.CallBroadcastsApi.Start((long)campaign.Id); campaign = Client.CallBroadcastsApi.Get((long)campaign.Id, "id,status"); Assert.AreEqual(BroadcastStatus.RUNNING, campaign.Status); // stop Client.CallBroadcastsApi.Stop((long)campaign.Id); campaign = Client.CallBroadcastsApi.Get((long)campaign.Id, "id,status"); Assert.AreEqual(BroadcastStatus.STOPPED, campaign.Status); // archive Client.CallBroadcastsApi.Archive((long)campaign.Id); campaign = Client.CallBroadcastsApi.Get((long)campaign.Id, "id,status"); Assert.AreEqual(BroadcastStatus.ARCHIVED, campaign.Status); }
public void StartStopArchiveCampaign() { var broadcast = new CallBroadcast { Name = "call_broadcast", AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", LiveSoundTextVoice = Voice.MALE1, MachineSoundText = "This is an answering machine text to speech recording", MachineSoundTextVoice = Voice.MALE1 }, Recipients = new List <CallRecipient> { new CallRecipient { PhoneNumber = "12132041238" }, new CallRecipient { PhoneNumber = "14246525473" } } }; var id = Client.CallBroadcastsApi.Create(broadcast, false); CallBroadcast campaign = Client.CallBroadcastsApi.Get(id.Id); System.Console.WriteLine(campaign); Assert.NotNull(campaign); // start Client.CallBroadcastsApi.Start((long)campaign.Id); campaign = Client.CallBroadcastsApi.Get((long)campaign.Id, "id,status"); Assert.AreEqual(BroadcastStatus.RUNNING, campaign.Status); // stop Client.CallBroadcastsApi.Stop((long)campaign.Id); campaign = Client.CallBroadcastsApi.Get((long)campaign.Id, "id,status"); Assert.AreEqual(BroadcastStatus.STOPPED, campaign.Status); // archive Client.CallBroadcastsApi.Archive((long)campaign.Id); campaign = Client.CallBroadcastsApi.Get((long)campaign.Id, "id,status"); Assert.AreEqual(BroadcastStatus.ARCHIVED, campaign.Status); }
public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var broadcast = new CallBroadcast() { Id = 11646003, Name = "Call Broadcast with Schedules", AnsweringMachineConfig = AnsweringMachineConfig.LIVE_IMMEDIATE, Sounds = new CallBroadcastSounds() { LiveSoundText = "Hello! This is an updated Call Broadcast config tts" }, Schedules = new List <Schedule>() { new Schedule { StartDate = new LocalDate { Year = 2016, Month = 12, Day = 1 }, StartTimeOfDay = new LocalTime { Hour = 10, Minute = 0, Second = 0 }, StopDate = new LocalDate { Year = 2016, Month = 12, Day = 10 }, StopTimeOfDay = new LocalTime { Hour = 18, Minute = 0, Second = 0 }, // set weekly schedule DaysOfWeek = new HashSet <DayOfWeek> { DayOfWeek.SATURDAY, DayOfWeek.SUNDAY }, // set optional time zone, if leave empty account's timezone will be used TimeZone = "America/New_York" } } }; // update campaign client.CallBroadcastsApi.Update(broadcast); }
public void UpdateIvrBroadcast() { var expectedJson = GetJsonPayload("/campaigns/callBroadcastsApi/request/updateIvrBroadcast.json"); var restRequest = MockRestResponse(expectedJson); var callBroadcast = new CallBroadcast { Id = 12, Name = "Example API IVR updated", FromNumber = "12135551189", DialplanXml = "<dialplan name=\"Root\">\r\n\t<play type=\"tts\">Congratulations! You have successfully configured a CallFire I V R.</play>\r\n</dialplan>" }; Client.CallBroadcastsApi.Update(callBroadcast); Assert.AreEqual(Method.PUT, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.AreEqual(requestBodyParam.Value, expectedJson); Assert.That(restRequest.Value.Resource, Is.StringEnding("/12")); }
public void CreateVoiceBroadcast() { var requestJson = GetJsonPayload("/campaigns/callBroadcastsApi/request/createCallBroadcast.json"); var responseJson = GetJsonPayload("/campaigns/callBroadcastsApi/response/createCallBroadcast.json"); var restRequest = MockRestResponse(responseJson); var callBroadcast = new CallBroadcast { Name = "Example API VB", FromNumber = "12135551189", AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", LiveSoundTextVoice = Voice.MALE1, MachineSoundText = "This is an answering machine text to speech recording", MachineSoundTextVoice = Voice.MALE1 }, Recipients = new List <CallRecipient> { new CallRecipient { PhoneNumber = "13233832214" }, new CallRecipient { PhoneNumber = "13233832215" }, }, ResumeNextDay = true }; var id = Client.CallBroadcastsApi.Create(callBroadcast, true, true); Assert.That(Serializer.Serialize(id), 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)); Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("start") && p.Value.Equals("True"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("strictValidation") && p.Value.Equals("True"))); }
/// <summary> /// Create a call broadcast campaign using the Call Broadcast API. A campaign can be created with /// no contacts and bare minimum configuration, but contacts will have to be added further on to use the campaign. /// If start set to true campaign starts immediately /// </summary> /// <param name="broadcast">call broadcast to create</param> /// <param name="start">if set to true then broadcast will start immediately, by default it set to false</param> /// <returns>ResourceId object with id of created broadcast</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 ResourceId Create(CallBroadcast broadcast, bool start = false) { var queryParams = ClientUtils.BuildQueryParams("start", start.ToString()); return(Client.Post <ResourceId>(CB_PATH, broadcast, queryParams)); }
public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var broadcast = new CallBroadcast { Name = "Call Broadcast", // set validated Caller ID number. FromNumber = "12135551189", // attach custom labels if needed Labels = new List <string> { "ivr tag", "id-10002" }, // allow CallFire to dial recipient only between 09:00 - 18:00 depending on // recipient's number area code timezone LocalTimeRestriction = new LocalTimeRestriction { BeginHour = 9, BeginMinute = 0, EndHour = 18, EndMinute = 0 }, // schedule a campaign to run on every Monday and Wednesday starting from 2016-12-01 10:00:00 Schedules = new List <Schedule> { new Schedule { StartDate = new LocalDate { Year = 2016, Month = 12, Day = 1 }, StartTimeOfDay = new LocalTime { Hour = 10, Minute = 0, Second = 0 }, // set weekly schedule DaysOfWeek = new HashSet <DayOfWeek> { DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY }, // set optional time zone, if leave empty account's timezone will be used TimeZone = "America/New_York" } }, // set retry configuration to attempt a contact's Mobile and Work phone numbers twice in case Call was // resulted to BUSY or No Answer response. Set 5 minutes between attempts. RetryConfig = new RetryConfig { MaxAttempts = 2, MinutesBetweenAttempts = 5, RetryResults = new List <RetryResults> { RetryResults.BUSY, RetryResults.NO_ANS }, RetryPhoneTypes = new List <RetryPhoneTypes> { RetryPhoneTypes.MOBILE_PHONE, RetryPhoneTypes.WORK_PHONE } }, // set IVR XML 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 a text message --> <play type=""tts"" voice=""female1"" name=""play_msg"">Hello, ${contact.firstName}, this is CallFire IVR message.</play> <!-- user has pressed 1, repeat starting from menu entry --> <keypress pressed=""1""> <goto>live</goto> </keypress> <!-- nothing is pressed for a 3500 milliseconds, hang up the phone --> <keypress pressed=""timeout""> <hangup/> </keypress> </menu> <hangup name=""hangup""/> </dialplan> " }; // create broadcast with 'start' argument = true to start campaign immediately var id = client.CallBroadcastsApi.Create(broadcast); }
public void ToggleRecipientsStatus() { var broadcast = new CallBroadcast { Name = "call_broadcast1", AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", LiveSoundTextVoice = Voice.MALE1, MachineSoundText = "This is an answering machine text to speech recording", MachineSoundTextVoice = Voice.MALE1 }, Recipients = new List <CallRecipient> { new CallRecipient { PhoneNumber = "12132212384" }, new CallRecipient { PhoneNumber = "12132212385" } }, ResumeNextDay = true }; var id = Client.CallBroadcastsApi.Create(broadcast, false, false); System.Console.WriteLine("broadcast id: " + id); var getCallsRequest = new GetByIdRequest { Id = id.Id }; var calls = Client.CallBroadcastsApi.GetCalls(getCallsRequest); Assert.That(calls.Items, Is.Not.Empty); foreach (Call c in calls.Items) { Assert.AreEqual(StateType.READY, c.State); } var recipients = new List <Recipient> { new Recipient { PhoneNumber = "12132212384" }, new Recipient { PhoneNumber = "12132212385" } }; Client.CallBroadcastsApi.ToggleRecipientsStatus(id.Id, recipients, false); calls = Client.CallBroadcastsApi.GetCalls(getCallsRequest); foreach (Call c in calls.Items) { Assert.AreEqual(StateType.DISABLED, c.State); } Client.CallBroadcastsApi.ToggleRecipientsStatus(id.Id, recipients, true); calls = Client.CallBroadcastsApi.GetCalls(getCallsRequest); foreach (Call c in calls.Items) { Assert.AreEqual(StateType.READY, c.State); } }
public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var broadcast = new CallBroadcast { Name = "Charity Campaign", // set validated Caller ID number. FromNumber = "12135551189", // attach custom labels if needed Labels = new List <string> { "charity", "id-10002" }, // allow CallFire to dial recipient only between 09:00 - 18:00 depending on // recipient's number area code timezone LocalTimeRestriction = new LocalTimeRestriction { BeginHour = 9, BeginMinute = 0, EndHour = 18, EndMinute = 0 }, // schedule a campaign to run on every Monday and Wednesday starting from 2016-12-01 10:00:00 Schedules = new List <Schedule> { new Schedule { StartDate = new LocalDate { Year = 2016, Month = 12, Day = 1 }, StartTimeOfDay = new LocalTime { Hour = 10, Minute = 0, Second = 0 }, // set weekly schedule DaysOfWeek = new HashSet <DayOfWeek> { DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY }, // set optional time zone, if leave empty account's timezone will be used TimeZone = "America/New_York" } }, // set retry configuration to attempt a contact's Mobile and Work phone numbers twice in case Call was // resulted to BUSY or No Answer response. Set 5 minutes between attempts. RetryConfig = new RetryConfig { MaxAttempts = 2, MinutesBetweenAttempts = 5, RetryResults = new List <RetryResults> { RetryResults.BUSY, RetryResults.NO_ANS }, RetryPhoneTypes = new List <RetryPhoneTypes> { RetryPhoneTypes.MOBILE_PHONE, RetryPhoneTypes.WORK_PHONE } }, // set IVR XML DialplanXml = @" <dialplan name=""Root""> <!-- answering machine detection --> <amd> <!-- if call is answered by human go to live menu --> <live> <goto name=""goto_Live"">Live</goto> </live> <machine> <goto name=""goto_Machine"">Machine</goto> </machine> </amd> <menu maxDigits=""1"" timeout=""3500"" name=""Live""> <play type=""tts"" voice=""female1"" name=""play_Live""> Hello ${contact.firstName}, we are organizing a charity weekend in November. Don't miss to visit it. Press ""1"" to follow the instructions how to order the tickets, press ""2"" if you are willing to become a volunteer at event. </play> <keypress pressed=""1"" name=""kp_order_tickets""> <!-- store recipient's answer and go to another menu to make a purchase --> <stash varname=""order"" name=""create_an_order"">Yes</stash> <goto>order_tickets</goto> </keypress> <keypress pressed=""2"" name=""kp_become_volonteer""> <!-- store recipient's answer --> <stash varname=""volonteer"" name=""become_volonteer"">Yes</stash> <play type=""tts"" voice=""female1"" name=""play_Goodbye_1""> Thanks for the response. We will call you later today. </play> <goto>Hangup</goto> </keypress> <!-- if pressed key is not specified in menu replay Live menu --> <keypress pressed=""default"" name=""incorrect_Selection""> <play type=""tts"" voice=""female1"" name=""play_Inorrect_Selection""> That is not a valid selection. Please try again. </play> <goto name=""replay_Live"">Live</goto> </keypress> </menu> <menu maxDigits=""1"" timeout=""3500"" name=""order_tickets""> <play type=""tts"" voice=""female1"" name=""play_order_tickets""> You will be transferred to Sales representative in a moment. Please wait. </play> <transfer callerid=""${call.callerid}"" musiconhold=""blues"" mode=""ringall""> 15551234567 </transfer> </menu> <play type=""tts"" voice=""female1"" name=""Goodbye""> Thank you for taking our survey </play> <goto name=""Goodbye_Hangup"">Hangup</goto> <play type=""tts"" voice=""female1"" name=""Machine""> Hello ${contact.firstName} ${contact.lastName}. We are organizing a charity weekend in November. If you would like to participate, please call 8 5 5, 5 5 5, 5 5 5 5. Thank you. </play> <hangup name=""Hangup""/> </dialplan> ", // add new recipients Recipients = new List <Recipient> { new Recipient { PhoneNumber = "12135551100", // set custom recipient attributes, they are available only to a single Call/Text // action, do not confuse them with contact fields which are stored with contact // and are available to each Call/Text where contact is attached to Attributes = new Dictionary <string, string> { { "age", "30" }, { "position", "Manager" } } }, new Recipient { PhoneNumber = "12135771188", Attributes = new Dictionary <string, string> { { "external_system_id", "34347770001" }, { "call_label", "friends" } } }, // You can use already existing contacts as a recipients new Recipient { ContactId = 46000044001 } } }; // create broadcast with 'start' argument = true to start campaign immediately var id = client.CallBroadcastsApi.Create(broadcast, false); }
public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var broadcast = new CallBroadcast { Name = "Call Broadcast", // set validated Caller ID number. FromNumber = "12135551189", // attach custom labels if needed Labels = new List <string> { "voice tag", "id-10002" }, // set answering machine detection AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, // set voice messages using TTS option for Live answers and when Answering Machine is detected. Sounds = new CallBroadcastSounds { LiveSoundText = "Hello! This is a live answer text to speech recording", MachineSoundText = "This is an answering machine text to speech recording", }, // allow CallFire to dial recipient only between 09:00 - 18:00 depending on // recipient's number area code timezone LocalTimeRestriction = new LocalTimeRestriction { BeginHour = 9, BeginMinute = 0, EndHour = 18, EndMinute = 0 }, // schedule a campaign to run on every Monday and Wednesday starting from 2016-12-01 10:00:00 Schedules = new List <Schedule> { new Schedule { StartDate = new LocalDate { Year = 2016, Month = 12, Day = 1 }, StartTimeOfDay = new LocalTime { Hour = 10, Minute = 0, Second = 0 }, // set weekly schedule DaysOfWeek = new HashSet <DayOfWeek> { DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY }, // set optional time zone, if leave empty account's timezone will be used TimeZone = "America/New_York" } }, // set retry configuration to attempt a contact's Mobile and Work phone numbers twice in case Call was // resulted to BUSY or No Answer response. Set 5 minutes between attempts. RetryConfig = new RetryConfig { MaxAttempts = 2, MinutesBetweenAttempts = 5, RetryResults = new List <RetryResults> { RetryResults.BUSY, RetryResults.NO_ANS }, RetryPhoneTypes = new List <RetryPhoneTypes> { RetryPhoneTypes.MOBILE_PHONE, RetryPhoneTypes.WORK_PHONE } } }; // create broadcast with 'start' argument = true to start campaign immediately var id = client.CallBroadcastsApi.Create(broadcast); }
public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var broadcast = new CallBroadcast { Name = "Political Campaign", // set validated Caller ID number. FromNumber = "12135551189", // attach custom labels if needed Labels = new List <string> { "political-poll", "id-10002" }, // allow CallFire to dial recipient only between 09:00 - 18:00 depending on // recipient's number area code timezone LocalTimeRestriction = new LocalTimeRestriction { BeginHour = 9, BeginMinute = 0, EndHour = 18, EndMinute = 0 }, // set retry configuration to attempt a contact's Mobile and Work phone numbers twice in case Call was // resulted to BUSY or No Answer response. Set 5 minutes between attempts. RetryConfig = new RetryConfig { MaxAttempts = 2, MinutesBetweenAttempts = 5, RetryResults = new List <RetryResults> { RetryResults.BUSY, RetryResults.NO_ANS }, RetryPhoneTypes = new List <RetryPhoneTypes> { RetryPhoneTypes.MOBILE_PHONE, RetryPhoneTypes.WORK_PHONE } }, // set IVR XML DialplanXml = @" <dialplan name=""Root""> <amd> <live> <goto name=""goto_Live"">Live</goto> </live> <machine> <goto name=""goto_Machine"">Machine</goto> </machine> </amd> <menu maxDigits=""1"" timeout=""3500"" name=""Live""> <play type=""tts"" voice=""female1"" name=""play_Live"">Hello. This is a call for a short political poll for the upcoming election. Will you vote in the upcoming election? Press 1 for Yes, or 2 for No..</play> <keypress pressed=""1"" name=""kp_Vote""> <stash varname=""Vote"" name=""stash_Will_Vote"">Yes</stash> <goto>Question_01</goto> </keypress> <keypress pressed=""2"" name=""kp_Will_Not_Vote""> <stash varname=""Vote"" name=""stash_Will_Not_Vote"">No</stash> <play type=""tts"" voice=""female1"" name=""play_Goodbye_1"">Thank you for your time. Goodbye.</play> <goto>Hangup</goto> </keypress> <keypress pressed=""default"" name=""incorrect_Selection""> <play type=""tts"" voice=""female1"" name=""play_Inorrect_Selection"">That is not a valid selection. Please try again.</play> <goto name=""replay_Live"">Live</goto> </keypress> </menu> <menu maxDigits=""1"" timeout=""3500"" name=""Question_01""> <play type=""tts"" voice=""female1"" name=""play_Question_01"">Who will you vote for in the upcoming elections? Press 1 for Donkeys. Press 2 for Elephants. Press 3 for Greenies, press 4 for Undecided, or, press 5 for Decline to state.</play> <keypress pressed=""1-5"" name=""Selection_Question_01""> <stash varname=""Candidate"" name=""stash_Candidate"">${call.lastinput}</stash> <goto name=""goto_Goodbye"">Goodbye</goto> </keypress> <keypress pressed=""default"" name=""incorrect_Selection_Question_01""> <play type=""tts"" voice=""female1"" name=""play_Inorrect_Selection_Question_01""> That is not a valid selection. Please try again. </play> <goto name=""replay_Question_01"">Question_01</goto> </keypress> </menu> <play type=""tts"" voice=""female1"" name=""Goodbye""> Thank you for taking our poll. Please remember to vote in the upcoming election! Thank you for your time. Goodbye. </play> <goto name=""Goodbye_Hangup"">Hangup</goto> <play type=""tts"" voice=""female1"" name=""Machine""> Hello. This is a call for a political poll for the upcoming election. Sorry we missed you. We will try you again later, or, if you would like to take this short poll, please call 8 5 5,5 5 5,5 5 5 5. Thank you.</play> <hangup name=""Hangup""/> </dialplan> " }; // create broadcast with 'start' argument = true to start campaign immediately var id = client.CallBroadcastsApi.Create(broadcast); }
/// <summary> /// Update broadcast /// </summary> /// <param name="broadcast">broadcast to update</param> /// <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 void Update(CallBroadcast broadcast) { Validate.NotNull(broadcast.Id, "broadcast.id cannot be null"); Client.Put <object>(CB_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, broadcast.Id.ToString()), broadcast); }
public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var broadcast = new CallBroadcast { Name = "Charity Campaign", // set validated Caller ID number. FromNumber = "12135551189", // attach custom labels if needed Labels = new List <string> { "charity", "id-10002" }, // set answering machine detection AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE, // set voice messages using TTS option for Live answers and when Answering Machine is detected. // you also can set a pre-defined TTS voice. Sounds = new CallBroadcastSounds { LiveSoundText = "Hello, this is Mary, from the local branch of Non-profit agency. " + "Do not miss our charity weekend taking place at first November weekends." + " We are looking forward to meet you there. Press '1' to to find out more details.", LiveSoundTextVoice = Voice.MALE1, MachineSoundText = "Hello, this is Mary, from the local branch of Non-profit agency. " + "If you are interested in charity weekend, please call (231) 455-7676.", MachineSoundTextVoice = Voice.MALE1, TransferSoundText = "Please wait a moment, call is being transfer.", // set number to transfer call to once transfer digit is pressed TransferDigit = "1", TransferNumber = "12314557676" }, // allow CallFire to dial recipient only between 09:00 - 18:00 depending on // recipient's number area code timezone LocalTimeRestriction = new LocalTimeRestriction { BeginHour = 9, BeginMinute = 0, EndHour = 18, EndMinute = 0 }, // schedule a campaign to run on every Monday and Wednesday starting from 2016-12-01 10:00:00 Schedules = new List <Schedule> { new Schedule { StartDate = new LocalDate { Year = 2016, Month = 12, Day = 1 }, StartTimeOfDay = new LocalTime { Hour = 10, Minute = 0, Second = 0 }, // set weekly schedule DaysOfWeek = new HashSet <DayOfWeek> { DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY }, // set optional time zone, if leave empty account's timezone will be used TimeZone = "America/New_York" } }, // set retry configuration to attempt a contact's Mobile and Work phone numbers twice in case Call was // resulted to BUSY or No Answer response. Set 5 minutes between attempts. RetryConfig = new RetryConfig { MaxAttempts = 2, MinutesBetweenAttempts = 5, RetryResults = new List <RetryResults> { RetryResults.BUSY, RetryResults.NO_ANS }, RetryPhoneTypes = new List <RetryPhoneTypes> { RetryPhoneTypes.MOBILE_PHONE, RetryPhoneTypes.WORK_PHONE } }, // add new recipients Recipients = new List <Recipient> { new Recipient { PhoneNumber = "12135551100", // set custom recipient attributes, they are available only to a single Call/Text // action, do not confuse them with contact fields which are stored with contact // and are available to each Call/Text where contact is attached to Attributes = new Dictionary <string, string> { { "age", "30" }, { "position", "Manager" } } }, new Recipient { PhoneNumber = "12135771188", Attributes = new Dictionary <string, string> { { "external_system_id", "34347770001" }, { "call_label", "friends" } } }, // You can use already existing contacts as a recipients new Recipient { ContactId = 46000044001 } } }; // create broadcast with 'start' argument = true to start campaign immediately var id = client.CallBroadcastsApi.Create(broadcast); }