Beispiel #1
0
        public void TestEngagementResource()
        {
            EngagementResource instance = new EngagementResource();

            instance.Name      = "Example";
            instance.Direction = "outbound";
            instance.Status    = "scheduled";

            Assert.AreEqual(instance.Name, "Example");
            Assert.AreEqual(instance.Direction, "outbound");
            Assert.AreEqual(instance.Status, "scheduled");
        }
Beispiel #2
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        EngagementResource.Delete(
            pathFlowSid: "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );
    }
        public void TestDeleteResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.NoContent,
                         "null"
                         ));

            var response = EngagementResource.Delete("FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);

            Assert.NotNull(response);
        }
        public void TestCreateResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.Created,
                         "{\"url\": \"https://studio.twilio.com/v1/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"sid\": \"FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"flow_sid\": \"FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"context\": {\"flow\": {\"first_name\": \"Foo\"}},\"contact_sid\": \"FCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"contact_channel_address\": \"+18001234567\",\"status\": \"active\",\"date_created\": \"2015-07-30T20:00:00Z\",\"date_updated\": \"2015-07-30T20:00:00Z\",\"links\": {\"steps\": \"https://studio.twilio.com/v1/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Steps\"}}"
                         ));

            var response = EngagementResource.Create("FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", new Twilio.Types.PhoneNumber("+15017122661"), new Twilio.Types.PhoneNumber("+15017122661"), client: twilioRestClient);

            Assert.NotNull(response);
        }
        public void TestReadEmptyResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"meta\": {\"previous_page_url\": null,\"next_page_url\": null,\"url\": \"https://studio.twilio.com/v1/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements?PageSize=50&Page=0\",\"page\": 0,\"first_page_url\": \"https://studio.twilio.com/v1/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements?PageSize=50&Page=0\",\"page_size\": 50,\"key\": \"engagements\"},\"engagements\": []}"
                         ));

            var response = EngagementResource.Read("FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);

            Assert.NotNull(response);
        }
        public void TestFetchResponse()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();

            twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
            twilioRestClient.Request(Arg.Any <Request>())
            .Returns(new Response(
                         System.Net.HttpStatusCode.OK,
                         "{\"sid\": \"FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"flow_sid\": \"FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"contact_sid\": \"FCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"contact_channel_address\": \"+14155555555\",\"status\": \"ended\",\"context\": {},\"date_created\": \"2017-11-06T12:00:00Z\",\"date_updated\": null,\"url\": \"https://studio.twilio.com/v1/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"links\": {\"steps\": \"https://studio.twilio.com/v1/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Steps\"}}"
                         ));

            var response = EngagementResource.Fetch("FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);

            Assert.NotNull(response);
        }
Beispiel #7
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var engagement = EngagementResource.Fetch(
            pathFlowSid: "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            pathSid: "FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(engagement.Sid);
    }
 /// <summary>
 /// Created By  : Dalz,Ranjith,Gouthami ella
 /// Created On  : 13 Jan , 2017
 /// Description : Delete an project for a resource
 /// </summary>
 /// <param name="engagementResource"></param>
 /// <returns></returns>
 public bool DeleteResourceProject(EngagementResource engagementResource)
 {
     try
     {
         EngagementResource _resourceExistDb = _unitOfWork.EngagementResourceRepository.GetSingle(x => x.ProjectId == engagementResource.ProjectId && x.ResourceId == engagementResource.ResourceId);
         if (_resourceExistDb == null)
         {
             return(false);
         }
         _unitOfWork.EngagementResourceRepository.DeleteWhere(x => x.ResourceId == engagementResource.ResourceId && x.ProjectId == engagementResource.ProjectId);
         _unitOfWork.Commit();
         return(true);
     }
     catch (Exception ex) { return(false); }
 }
Beispiel #9
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var engagement = EngagementResource.Create(
            to: new Twilio.Types.PhoneNumber("+15017122661"),
            from: new Twilio.Types.PhoneNumber("+15017122661"),
            pathFlowSid: "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(engagement.Sid);
    }
Beispiel #10
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var engagements = EngagementResource.Read(
            pathFlowSid: "FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        foreach (var record in engagements)
        {
            Console.WriteLine(record.Sid);
        }
    }
        public void TestFetchRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Get,
                Twilio.Rest.Domain.Studio,
                "/v1/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                ""
                );

            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                EngagementResource.Fetch("FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
Beispiel #12
0
 public IActionResult DeleteResourceProject([FromBody] EngagementResource engagementResource)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         bool status = projectModel.DeleteResourceProject(engagementResource);
         if (status)
         {
             return(Ok());
         }
         else
         {
             return(new NotFoundResult());
         }
     }
     catch (Exception ex) { return(BadRequest(ex)); }
 }
        public void TestCreateRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Post,
                Twilio.Rest.Domain.Studio,
                "/v1/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements",
                ""
                );

            request.AddPostParam("To", Serialize(new Twilio.Types.PhoneNumber("+15017122661")));
            request.AddPostParam("From", Serialize(new Twilio.Types.PhoneNumber("+15017122661")));
            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                EngagementResource.Create("FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", new Twilio.Types.PhoneNumber("+15017122661"), new Twilio.Types.PhoneNumber("+15017122661"), client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
Beispiel #14
0
        /// <summary>
        /// To run this application, the following is required:
        ///
        /// - API token key/secret from Account -> Developer -> API Tokens
        /// - A verified Phone Number UUID from Account -> Telephony -> Phone Numbers -> Edit (in the URI)
        /// - Fill in variables to run example
        /// </summary>
        /// <param name="args"></param>
        async static Task Main(string[] args)
        {
            var tokenKey    = "";
            var tokenSecret = "";

            // Set the Phone Number ID (e.g., GncieHvbCKfMYXmeycoWZm)
            var phoneNumberId = "";

            // Sample contact information to call
            var firstName   = "";
            var lastName    = "";
            var phoneNumber = ""; // In E.164 format (such as +1xxxxxxxxx)

            // Initialize SDK
            OmnigageClient.Init(tokenKey, tokenSecret);

            var engagement = new EngagementResource
            {
                Name      = "Example SMS Blast",
                Direction = "outbound"
            };
            await engagement.Create();

            var template = new TextTemplateResource
            {
                Name = "Text Template",
                Body = "Sample body"
            };
            await template.Create();

            var activity = new ActivityResource
            {
                Name         = "SMS Blast",
                Kind         = ActivityKind.Text,
                Engagement   = engagement,
                TextTemplate = template,
                PhoneNumber  = new PhoneNumberResource
                {
                    Id = phoneNumberId
                }
            };
            await activity.Create();

            var envelope = new EnvelopeResource
            {
                PhoneNumber = phoneNumber,
                Engagement  = engagement,
                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 TestEmailEngagement()
        {
            var scotchMode = ScotchMode.Replaying;
            var client     = HttpClients.NewHttpClient("IntegrationTests/Cassettes/EngagementEmailTests.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 Blast";
            engagement.Direction = "outbound";

            await engagement.Create();

            EmailTemplateResource emailTemplate = new EmailTemplateResource();

            emailTemplate.Subject = "Ahoy";
            emailTemplate.Body    = "Sample body";

            await emailTemplate.Create();

            ActivityResource activity = new ActivityResource();

            activity.Name          = "Email Blast";
            activity.Kind          = ActivityKind.Email;
            activity.Engagement    = engagement;
            activity.EmailTemplate = emailTemplate;
            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();
        }
Beispiel #16
0
        async public Task TestVoiceEngagement()
        {
            var mockHttp           = new MockHttpMessageHandler();
            var engagementResponse = File.ReadAllText("UnitTests/Serialized/ResourceTestsEngagementResponse.json");
            var activityResponse   = File.ReadAllText("UnitTests/Serialized/ResourceTestsActivityResponse.json");
            var triggerResponse    = File.ReadAllText("UnitTests/Serialized/ResourceTestsTriggerResponse.json");
            var envelopeRequest    = File.ReadAllText("UnitTests/Serialized/ResourceTestsEnvelopeBulkRequest.json");

            mockHttp.When(HttpMethod.Post, "http://localhost/api/engagements")
            .Respond(System.Net.HttpStatusCode.Created, "application/json", engagementResponse);
            mockHttp.When(HttpMethod.Post, "http://localhost/api/activities")
            .Respond(System.Net.HttpStatusCode.Created, "application/json", activityResponse);
            mockHttp.When(HttpMethod.Post, "http://localhost/api/triggers")
            .Respond(System.Net.HttpStatusCode.Created, "application/json", triggerResponse);

            var httpClient = mockHttp.ToHttpClient();

            OmnigageClient.Init("key", "secret", "http://localhost/api/", httpClient);

            EngagementResource engagement = new EngagementResource();

            engagement.Name      = "Example";
            engagement.Direction = "outbound";
            engagement.Status    = "scheduled";

            await engagement.Create();

            Assert.AreEqual(engagement.Id, "1");
            Assert.AreEqual(engagement.ToString(), engagementResponse);

            ActivityResource activity = new ActivityResource();

            activity.Name       = "Voice Blast";
            activity.Kind       = "voice";
            activity.Engagement = engagement;
            activity.CallerId   = new CallerIdResource
            {
                Id = "yL9vQaWrSqg5W8EFEpE6xZ"
            };

            await activity.Create();

            Assert.AreEqual(activity.Id, "1");
            Assert.AreEqual(activity.Name, "Voice Blast");
            Assert.AreEqual(activity.Kind, "voice");

            TriggerResource trigger = new TriggerResource();

            trigger.Kind          = "play";
            trigger.OnEvent       = "voice-machine";
            trigger.Activity      = activity;
            trigger.VoiceTemplate = new VoiceTemplateResource
            {
                Id = "RaF56o2r58hTKT7AYS9doj"
            };

            await trigger.Create();

            Assert.AreEqual(trigger.Id, "1");
            Assert.AreEqual(trigger.Kind, "play");
            Assert.AreEqual(trigger.OnEvent, "voice-machine");

            EnvelopeResource envelope = new EnvelopeResource();

            envelope.PhoneNumber = "+11111111111";
            envelope.Engagement  = engagement;
            envelope.Meta        = new Dictionary <string, string>
            {
                { "first-name", "Michael" },
                { "last-name", "Morgan" }
            };

            List <EnvelopeResource> envelopes = new List <EnvelopeResource> {
            };

            envelopes.Add(envelope);

            string envelopesPayload = EnvelopeResource.SerializeBulk(envelopes);

            Assert.AreEqual(envelopesPayload, envelopeRequest);
        }
        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();
        }
        async public Task TestTextEngagement()
        {
            var scotchMode = ScotchMode.Replaying;
            var client     = HttpClients.NewHttpClient("IntegrationTests/Cassettes/EngagementTextTests.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 Text Blast";
            engagement.Direction = "outbound";

            await engagement.Create();

            TextTemplateResource textTemplate = new TextTemplateResource();

            textTemplate.Name = "Text Template";
            textTemplate.Body = "Sample body";

            await textTemplate.Create();

            ActivityResource activity = new ActivityResource();

            activity.Name         = "Text Blast";
            activity.Kind         = ActivityKind.Text;
            activity.Engagement   = engagement;
            activity.TextTemplate = textTemplate;
            activity.PhoneNumber  = new PhoneNumberResource
            {
                Id = "GncieHvbCKfMYXmeycoWZm"
            };

            await activity.Create();

            EnvelopeResource envelope = new EnvelopeResource();

            envelope.PhoneNumber = "+14076413749";
            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 Client.PostBulkRequest("envelopes", EnvelopeResource.SerializeBulk(envelopes));

            // Schedule engagement for processing
            engagement.Status = "scheduled";
            await engagement.Update();
        }
        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
        /// - A verified Email ID UUID from Account -> Email -> Email IDs -> Edit (in the URI)
        /// - Fill in variables to run example
        /// </summary>
        /// <param name="args"></param>
        async static Task Main(string[] args)
        {
            var tokenKey    = "";
            var tokenSecret = "";

            // Set the Email ID (e.g., NbXW9TCHax9zfAeDhaY2bG)
            var emailId = "";

            // Sample contact information to call
            var firstName    = "";
            var lastName     = "";
            var emailAddress = "";

            // Initialize SDK
            OmnigageClient.Init(tokenKey, tokenSecret);

            var engagement = new EngagementResource();

            engagement.Name      = "Example Email Blast";
            engagement.Direction = "outbound";
            await engagement.Create();

            var emailTemplate = new EmailTemplateResource();

            emailTemplate.Subject = "Ahoy";
            emailTemplate.Body    = "Sample body";

            await emailTemplate.Create();

            var activity = new ActivityResource();

            activity.Name          = "Email Blast";
            activity.Kind          = ActivityKind.Email;
            activity.Engagement    = engagement;
            activity.EmailTemplate = emailTemplate;
            activity.EmailId       = new EmailIdResource
            {
                Id = emailId
            };
            await activity.Create();

            var envelope = new EnvelopeResource();

            envelope.EmailAddress = emailAddress;
            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();
        }
        /// <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();
        }