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 = "+6499293000"; const string billing_account = "TEST BILLING ACCOUNT"; const string recipient1 = "+64211111111"; const string recipient2 = "+64212222222"; const string recipient3 = "+64213333333"; const string recipient4 = "+64214444444"; const string message_to_people = "C:\\Message1.wav"; const string message_to_answerphones = "C:\\Message2.wav"; const string call_route_message_to_people = "C:\\Message3.wav"; const string call_route_message_to_operators = "C:\\Message4.wav"; const string call_route_message_on_wrong_key = "C:\\Message5.wav"; const int number_of_operators = 1; 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.NumberOfOperators = number_of_operators; #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<Keypad>()) // List<Keypad> keypad_list = new List<Keypad>(); keypad_list.Add(new Keypad(3, keypad3_route)); // // Add Keypad Method 4 - AddKeypad(new List<Keypad>()) using Keypad objects // Keypad keypad4 = new Keypad(); keypad4.Tone = 4; keypad4.RouteNumber = keypad4_route; keypad_list.Add(keypad4); 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<Recipient>()); using simple destination // List<Recipient> recipients = new List<Recipient>(); recipients.Add(new Recipient(recipient3)); // // Add Recipient Method 4 - AddRecipients(new List<Recipient>()) 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(); if (response.Result == MessageResult.ResultCode.Success) { Console.WriteLine("Success - " + response.MessageID); } else { Console.WriteLine("Error - " + response.ErrorMessage); } } } }