async public Task TestEmailVoiceEngagement() { var scotchMode = ScotchMode.Replaying; var client = HttpClients.NewHttpClient("IntegrationTests/Cassettes/EngagementEmailVoiceTests.json", scotchMode); string tokenKey = "key"; string tokenSecret = "secret"; string host = "https://dvfoa3pu2rxx6.cloudfront.net/api/v1/"; OmnigageClient.Init(tokenKey, tokenSecret, host, client); EngagementResource engagement = new EngagementResource(); engagement.Name = "Example Email Voice Blast (Voice Link)"; engagement.Direction = "outbound"; await engagement.Create(); EmailTemplateResource emailTemplate = new EmailTemplateResource(); emailTemplate.Subject = "Email Template"; emailTemplate.Body = "Email template with {{message-body}}."; await emailTemplate.Create(); EmailMessageResource emailMessage = new EmailMessageResource(); emailMessage.Subject = "Email Message"; emailMessage.Body = "Sample body"; emailMessage.IsDraft = true; await emailMessage.Create(); UploadResource upload1 = new UploadResource { FilePath = "Media/hello.mp3" }; await upload1.Create(); VoiceTemplateResource recording = new VoiceTemplateResource(); recording.Name = "Voice Link Recording"; recording.Kind = "audio"; recording.Upload = upload1; await recording.Create(); ActivityResource activity = new ActivityResource(); activity.Name = "Email Voice"; activity.Kind = ActivityKind.EmailVoice; activity.CallBackPhoneNumber = "+11231231234"; activity.Engagement = engagement; activity.VoiceTemplate = recording; activity.EmailTemplate = emailTemplate; activity.EmailMessage = emailMessage; activity.EmailId = new EmailIdResource { Id = "NbXW9TCHax9zfAeDhaY2bG" }; await activity.Create(); EnvelopeResource envelope = new EnvelopeResource(); envelope.EmailAddress = "*****@*****.**"; envelope.Engagement = engagement; envelope.Meta = new Dictionary <string, string> { { "first-name", "Omnigage" }, { "last-name", "Demo" } }; // Push one or more envelopes into list List <EnvelopeResource> envelopes = new List <EnvelopeResource> { }; envelopes.Add(envelope); // Populate engagement queue await OmnigageClient.PostBulkRequest("envelopes", EnvelopeResource.SerializeBulk(envelopes)); // Schedule engagement for processing engagement.Status = "scheduled"; await engagement.Update(); }
/// <summary> /// To run this application, the following is required: /// /// - API token key/secret from Account -> Developer -> API Tokens /// - Two audio files (either wav or mp3) /// - A Caller ID UUID from Account -> Telephony -> Caller IDs -> Edit (in the URI) /// </summary> /// <param name="args"></param> async static Task Main(string[] args) { string tokenKey = ""; string tokenSecret = ""; // Set the Caller ID (e.g., yL9vQaWrSqg5W8EFEpE6xZ) string callerId = ""; // Sample contact information to call string firstName = ""; string lastName = ""; string phoneNumber = ""; // In E.164 format with country code (e.g., +11235551234) // Audio path for when human is detected string audioFilePath1 = ""; // Full path to audio file (e.g., /Users/Shared/piano.wav on Mac) // Audio path for machine detection string audioFilePath2 = ""; // Full path to audio file (e.g., /Users/Shared/nimoy_spock.wav on Mac) // Initialize SDK OmnigageClient.Init(tokenKey, tokenSecret); var engagement = new EngagementResource(); engagement.Name = "Example Voice Blast"; engagement.Direction = "outbound"; await engagement.Create(); var activity = new ActivityResource(); activity.Name = "Voice Blast"; activity.Kind = ActivityKind.Voice; activity.Engagement = engagement; activity.CallerId = new CallerIdResource { Id = callerId }; await activity.Create(); var upload1 = new UploadResource { FilePath = audioFilePath1 }; await upload1.Create(); var upload2 = new UploadResource { FilePath = audioFilePath2 }; await upload2.Create(); var humanRecording = new VoiceTemplateResource(); humanRecording.Name = "Human Recording"; humanRecording.Kind = "audio"; humanRecording.Upload = upload1; await humanRecording.Create(); var machineRecording = new VoiceTemplateResource(); machineRecording.Name = "Machine Recording"; machineRecording.Kind = "audio"; machineRecording.Upload = upload2; await machineRecording.Create(); // Define human trigger var triggerHumanInstance = new TriggerResource(); triggerHumanInstance.Kind = TriggerKind.Play; triggerHumanInstance.OnEvent = TriggerOnEvent.VoiceHuman; triggerHumanInstance.Activity = activity; triggerHumanInstance.VoiceTemplate = humanRecording; await triggerHumanInstance.Create(); // Define machine trigger var triggerMachineInstance = new TriggerResource(); triggerMachineInstance.Kind = TriggerKind.Play; triggerMachineInstance.OnEvent = TriggerOnEvent.VoiceMachine; triggerMachineInstance.Activity = activity; triggerMachineInstance.VoiceTemplate = machineRecording; await triggerMachineInstance.Create(); var envelope = new EnvelopeResource(); envelope.PhoneNumber = phoneNumber; envelope.Engagement = engagement; envelope.Meta = new Dictionary <string, string> { { "first-name", firstName }, { "last-name", lastName } }; // Push one or more envelopes into list List <EnvelopeResource> envelopes = new List <EnvelopeResource> { }; envelopes.Add(envelope); // Populate engagement queue await Client.PostBulkRequest("envelopes", EnvelopeResource.SerializeBulk(envelopes)); // Schedule engagement for processing engagement.Status = "scheduled"; await engagement.Update(); }
async public Task TestVoiceEngagement() { var scotchMode = ScotchMode.Replaying; var client = HttpClients.NewHttpClient("IntegrationTests/Cassettes/EngagementTests.json", scotchMode); string tokenKey = "key"; string tokenSecret = "secret"; string host = "https://dvfoa3pu2rxx6.cloudfront.net/api/v1/"; OmnigageClient.Init(tokenKey, tokenSecret, host, client); EngagementResource engagement = new EngagementResource(); engagement.Name = "Example Voice Blast"; engagement.Direction = "outbound"; await engagement.Create(); ActivityResource activity = new ActivityResource(); activity.Name = "Voice Blast"; activity.Kind = ActivityKind.Voice; activity.Engagement = engagement; activity.CallerId = new CallerIdResource { Id = "yL9vQaWrSqg5W8EFEpE6xZ" }; await activity.Create(); UploadResource upload1 = new UploadResource { FilePath = "Media/hello.mp3" }; await upload1.Create(); UploadResource upload2 = new UploadResource { FilePath = "Media/you-have-new-mail-waiting.wav" }; await upload2.Create(); VoiceTemplateResource humanRecording = new VoiceTemplateResource(); humanRecording.Name = "Human Recording"; humanRecording.Kind = "audio"; humanRecording.Upload = upload1; await humanRecording.Create(); VoiceTemplateResource machineRecording = new VoiceTemplateResource(); machineRecording.Name = "Machine Recording"; machineRecording.Kind = "audio"; machineRecording.Upload = upload2; await machineRecording.Create(); // Define human trigger TriggerResource triggerHumanInstance = new TriggerResource(); triggerHumanInstance.Kind = TriggerKind.Play; triggerHumanInstance.OnEvent = TriggerOnEvent.VoiceHuman; triggerHumanInstance.Activity = activity; triggerHumanInstance.VoiceTemplate = humanRecording; await triggerHumanInstance.Create(); // Define machine trigger TriggerResource triggerMachineInstance = new TriggerResource(); triggerMachineInstance.Kind = TriggerKind.Play; triggerMachineInstance.OnEvent = TriggerOnEvent.VoiceMachine; triggerMachineInstance.Activity = activity; triggerMachineInstance.VoiceTemplate = machineRecording; await triggerMachineInstance.Create(); EnvelopeResource envelope = new EnvelopeResource(); envelope.PhoneNumber = "+18332676094"; envelope.Engagement = engagement; envelope.Meta = new Dictionary <string, string> { { "first-name", "Spectrum" }, { "last-name", "Support" } }; // Push one or more envelopes into list List <EnvelopeResource> envelopes = new List <EnvelopeResource> { }; envelopes.Add(envelope); // Populate engagement queue await OmnigageClient.PostBulkRequest("envelopes", EnvelopeResource.SerializeBulk(envelopes)); // Schedule engagement for processing engagement.Status = "scheduled"; await engagement.Update(); }