using System; using System.Collections.Generic; using TNZAPI.Messaging.Objects; using TNZAPI.Messaging.Send; namespace TNZTTSAdvanced { class Program { static void Main(string[] args) { const string sender = "application@domain.com"; const string api_key = "ta8wr7ymd"; const string reference = "Test TTS - Advanced version"; const string caller_id = "+6495005000"; const string billing_account = "TEST BILLING ACCOUNT"; const string recipient1 = "+6421000001"; const string recipient2 = "+6495005002"; const string recipient3 = "+6495005003"; const string recipient4 = "+6495005004"; const string message_to_people = "Hello, this is a call from Department01. This is relevant information. Press one to be connected to our call centre."; const string message_to_answerphones = "Hello, sorry we missed you. This is a call from Department 01. Please contact us on 0800 123123."; const string call_route_message_to_people = "Connecting you now."; const string call_route_message_to_operators = "Incoming Text To Speech call."; const string call_route_message_on_wrong_key = "Sorry, you have pressed an invalid key. Please try again."; const int number_of_operators = 1; const TTS.TTSVoiceType tts_voice = TTS.TTSVoiceType.Female2; const string keypad1_route = "+64800111111"; const string keypad2_route = "+64800222222"; const string keypad3_route = "+64800333333"; const string keypad4_route = "+64800444444"; TTS TTSMessage = new TTS(sender, api_key); #region Call Options TTSMessage.Reference = reference; TTSMessage.CallerID = caller_id; TTSMessage.SubAccount = billing_account; TTSMessage.NumberOfOperators = number_of_operators; #endregion Call Options #region Submit TextToSpeech Messagess // // Submit TextToSpeech Messagess (Text format only) // TTSMessage.AddMessageData(TTS.MessageDataType.MessageToPeople, message_to_people); TTSMessage.AddMessageData(TTS.MessageDataType.MessageToAnswerPhones, message_to_answerphones); TTSMessage.AddMessageData(TTS.MessageDataType.CallRouteMessageToPeople, call_route_message_to_people); TTSMessage.AddMessageData(TTS.MessageDataType.CallRouteMessageToOperators, call_route_message_to_operators); TTSMessage.AddMessageData(TTS.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); // TTSMessage.AddKeypad(1, keypad1_route); // // Add Keypad Method 2 - AddKeypad(new Keypad()); // TTSMessage.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); TTSMessage.AddKeypads(keypad_list); #endregion Add Keypads #region Add Recipients // // Add Recipient Method 1 - AddRecipient(string recipient); // TTSMessage.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 TTSMessage.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 )); TTSMessage.AddRecipients(recipients); #endregion Add Recipients MessageResult response = TTSMessage.SendMessage( "", // MessageID - Leave blank to auto-generate reference, // Reference new DateTime(), // SendTime "New Zealand", // Timezone billing_account, // Billing Account (SubAccount) "", // Department "", // ChargeCode number_of_operators, // No of Operators - Limits the maximum simultaneous calls caller_id, // Caller ID tts_voice, // Text-to-Speech voice to use (Male1, Female1, Female2, Female3, Female4) "" // Options ); if (response.Result == MessageResult.ResultCode.Success) { Console.WriteLine("Success - " + response.MessageID); } else { Console.WriteLine("Error - " + response.ErrorMessage); } } } }