using System; using System.Collections.Generic; using TNZAPI.Messaging.Objects; using TNZAPI.Messaging.Send; namespace TNZVoiceAdvanced { class Program { static void Main(string[] args) { const string sender = "YOUR_EMAIL_ADDRESS"; const string api_key = "YOUR_API_KEY"; const string reference = "Test Voice - Advanced version"; const string caller_id = "+6499999999"; const string billing_account = "TEST BILLING ACCOUNT"; const string report_to = "report@example.com"; const string recipient1 = "+64211111111"; const string recipient2 = "+64212222222"; const string recipient3 = "+64213333333"; const string recipient4 = "+64214444444"; const string message_to_people = "C:\\Voice1.wav"; // WAV format, 16-bit, 8000hz const string message_to_answerphones = "C:\\Voice2.wav"; // WAV format, 16-bit, 8000hz const string call_route_message_to_people = "C:\\Voice3.wav"; // WAV format, 16-bit, 8000hz const string call_route_message_to_operators = "C:\\Voice4.wav"; // WAV format, 16-bit, 8000hz const string call_route_message_on_wrong_key = "C:\\Voice5.wav"; // WAV format, 16-bit, 8000hz const int number_of_operators = 1; const int retry_attempts = 2; const int retry_period = 5; const string keypad1_route = "+6491111111"; const string keypad2_route = "+6492222222"; const string keypad3_route = "+6493333333"; const string keypad4_route = "+6494444444"; Voice VoiceMessage = new Voice(sender, api_key); #region Call Options VoiceMessage.Reference = reference; VoiceMessage.CallerID = caller_id; VoiceMessage.SubAccount = billing_account; VoiceMessage.ReportTo = report_to; VoiceMessage.NumberOfOperators = number_of_operators; VoiceMessage.RetryAttempts = retry_attempts; VoiceMessage.RetryPeriod = retry_period; #endregion Call Options #region Submit Audio Files // // Submit audio files - WAV format, 16-bit, 8000hz // VoiceMessage.AddMessageData(Voice.MessageDataType.MessageToPeople, message_to_people); VoiceMessage.AddMessageData(Voice.MessageDataType.MessageToAnswerPhones, message_to_answerphones); VoiceMessage.AddMessageData(Voice.MessageDataType.CallRouteMessageToPeople, call_route_message_to_people); VoiceMessage.AddMessageData(Voice.MessageDataType.CallRouteMessageToOperators, call_route_message_to_operators); VoiceMessage.AddMessageData(Voice.MessageDataType.CallRouteMessageOnWrongKey, call_route_message_on_wrong_key); #endregion Submit Audio Files #region Add Keypads // // Add Keypad Method 1 - VoiceMessage.AddKeypad(int key, string keypad1_route); // VoiceMessage.AddKeypad(1, keypad1_route); // // Add Keypad Method 2 - AddKeypad(new Keypad()); // VoiceMessage.AddKeypad(new Keypad(2, keypad2_route)); // // Add Keypad Method 3 - AddKeypad(new List()) // List keypad_list = new List(); keypad_list.Add(new Keypad(3, keypad3_route)); // // Add Keypad Method 4 - AddKeypad(new List()) using Keypad objects // Keypad keypad4 = new Keypad(); keypad4.Tone = 4; keypad4.RouteNumber = keypad4_route; keypad_list.Add(keypad4); // // Add Keypad Method 5 - Add Play (Wave Data) // Keypad keypad5 = new Keypad(); keypad5.Tone = 5; keypad5.PlayFile = "C:\\keypad5.wav"; keypad_list.Add(keypad5); VoiceMessage.AddKeypads(keypad_list); #endregion Add Keypads #region Add Recipients // // Add Recipient Method 1 - AddRecipient(string recipient); // VoiceMessage.AddRecipient(recipient1); // // Add Recipient Method 2 - AddRecipient(new Recipient()) // Recipient recipient = new Recipient(recipient2); recipient.CompanyName = "Test Company"; // Company Name recipient.Attention = "Test Recipient 2"; // Attention recipient.Custom1 = "Custom1"; // Custom1 recipient.Custom2 = "Custom2"; // Custom2 recipient.Custom3 = "Custom3"; // Custom3 recipient.Custom4 = "Custom4"; // Custom4 recipient.Custom5 = "Custom5"; // Custom5 //VoiceMessage.AddRecipient(recipient); // // Add Recipient Method 3 - AddRecipients(new List()); using simple destination // List recipients = new List(); recipients.Add(new Recipient(recipient3)); // // Add Recipient Method 4 - AddRecipients(new List()) using Recipient objects // recipients.Add(new Recipient( recipient4, // Recipient "Test Company", // Company Name "Test Recipient 4", // Attention "Custom1", // Custom1 "Custom2", // Custom2 "Custom3", // Custom3 "Custom4", // Custom4 "Custom5" // Custom5 )); VoiceMessage.AddRecipients(recipients); #endregion Add Recipients MessageResult response = VoiceMessage.SendMessage( "", // MessageID - Leave blank to auto-generate reference, // Reference new DateTime(), // SendTime "New Zealand", // Timezone billing_account, // Billing Account (Sub Account) "", // Department "", // Charge Code number_of_operators, // No of Operators - Limits the maximum simultaneous calls caller_id, // Caller ID "" // Options ); if (response.Result == MessageResult.ResultCode.Success) { Console.WriteLine("Success - " + response.MessageID); } else { Console.WriteLine("Error - " + response.ErrorMessage); } } } }