コード例 #1
0
        static void Main(string[] args)
        {
            // OAuth input
            Console.Write("Enter Client ID: ");
            string clientId = Console.ReadLine();

            Console.Write("Enter Client Secret: ");
            string clientSecret = Console.ReadLine();

            // Configure SDK Settings
            var    accessTokenInfo = Configuration.Default.ApiClient.PostToken(clientId, clientSecret);
            string accessToken     = accessTokenInfo.AccessToken;

            PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;

            // Instantiate APIs
            ConversationsApi conversationsApi = new ConversationsApi();

            // Build request body
            SendAgentlessOutboundMessageRequest request = new SendAgentlessOutboundMessageRequest();

            request.FromAddress            = "+13178723000";
            request.ToAddress              = "+15557655942";
            request.ToAddressMessengerType = SendAgentlessOutboundMessageRequest.ToAddressMessengerTypeEnum.Sms;
            request.TextBody = "Hello, this is a test notification";

            // Call to PostConversationsMessagesAgentless function of Conversations API
            SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request);

            // Final Output
            Console.WriteLine(response.ToString());
        }
コード例 #2
0
        // >> START recordings-downloader-step-1
        public static void authentication()
        {
            //OAuth
            clientId     = Environment.GetEnvironmentVariable("GENESYS_CLOUD_CLIENT_ID");
            clientSecret = Environment.GetEnvironmentVariable("GENESYS_CLOUD_CLIENT_SECRET");
            // orgRegion values example: us_east_1
            string orgRegion = Environment.GetEnvironmentVariable("GENESYS_CLOUD_REGION");

            // Set Region
            PureCloudRegionHosts region = Enum.Parse <PureCloudRegionHosts>(orgRegion);

            Configuration.Default.ApiClient.setBasePath(region);

            // >> START recordings-downloader-step-3
            // >> START recordings-downloader-step-2
            // Configure SDK Settings
            var accessTokenInfo = Configuration.Default.ApiClient.PostToken(clientId, clientSecret);

            Configuration.Default.AccessToken = accessTokenInfo.AccessToken;
            // >> END recordings-downloader-step-2
            // >> END recordings-downloader-step-3
            // >> END recordings-downloader-step-1

            // >> START recordings-downloader-step-4
            // Create API instances
            conversationsApi = new ConversationsApi();
            recordingApi     = new RecordingApi();
            // >> END recordings-downloader-step-4

            Console.WriteLine("Working...");
        }
コード例 #3
0
        public static void authentication()
        {
            //OAuth input
            Console.Write("Enter Client ID: ");
            clientId = Console.ReadLine();
            Console.Write("Enter Client Secret: ");
            clientSecret = Console.ReadLine();

            // Get the Date Interval
            Console.Write("Enter Date Interval (YYYY-MM-DDThh:mm:ss/YYYY-MM-DDThh:mm:ss): ");
            dates = Console.ReadLine();

            Console.WriteLine("Working...");

            //Set Region
            PureCloudRegionHosts region = PureCloudRegionHosts.us_east_1;

            Configuration.Default.ApiClient.setBasePath(region);

            // Configure SDK Settings
            var accessTokenInfo = Configuration.Default.ApiClient.PostToken(clientId, clientSecret);

            Configuration.Default.AccessToken = accessTokenInfo.AccessToken;

            // Create API instances
            conversationsApi = new ConversationsApi();
            recordingApi     = new RecordingApi();
        }
コード例 #4
0
        public Interactions(ListBox lstLog)
        {
            _lstLog = lstLog;

            conversationsApi  = new ConversationsApi();
            conversationQuery = new ConversationQuery();
            api = new AnalyticsApi();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            // OAuth input
            Console.Write("Enter Client ID: ");
            string clientId = Console.ReadLine();

            Console.Write("Enter Client Secret: ");
            string clientSecret = Console.ReadLine();

            // Get the Date Interval
            Console.Write("Enter Date Interval (YYYY-MM-DDThh:mm:ss/YYYY-MM-DDThh:mm:ss): ");
            string interval = Console.ReadLine();

            Console.WriteLine("Working...");

            // Configure SDK Settings
            string accessToken = GetToken(clientId, clientSecret);

            PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;

            // Instantiate APIs
            ConversationsApi conversationsApi = new ConversationsApi();
            RecordingApi     recordingApi     = new RecordingApi();

            // Get Conversation IDs and corresponding Media Type within a date interval
            Dictionary <string, AnalyticsSession.MediaTypeEnum> conversationsMapIDType = GetConversations(interval, conversationsApi);

            // Use the Conversation IDs and request a batch download for the conversations
            string jobId = RequestBatchDownload(conversationsMapIDType.Keys.ToList(), recordingApi);

            // Get all conversations with recordings
            List <BatchDownloadJobResult> jobResults = GetJobResults(jobId, recordingApi);

            // Download all the recordings and separate into folders named after the Conversation ID
            Console.WriteLine("Currently Downloading...");
            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            path = path.Substring(0, path.LastIndexOf("bin"));

            foreach (var job in jobResults)
            {
                // Create the directories for each unique Conversation IDs
                System.IO.Directory.CreateDirectory(path + "\\recordings\\" + job.ConversationId);

                // Determine the file extension to assign
                string extension = GetExtensionFromMediaType(conversationsMapIDType[job.ConversationId]);

                DownloadRecording(job.ResultUrl, path + "recordings\\" + job.ConversationId, extension);
            }

            // Final Output
            Console.WriteLine("DONE");

            if (Debugger.IsAttached)
            {
                Console.ReadKey();
            }
        }
コード例 #6
0
        static async Task Main(string[] args)
        {
            var QueueId      = "";
            var ClientId     = "";
            var ClientSecret = "";
            var Environment  = "mypurecloud.ie";

            var _apiClient     = new ApiClient($"https://api.{Environment}");
            var _configuration = new Configuration(_apiClient);

            _apiClient.Configuration = _configuration;

            var _conversationsApi = new ConversationsApi(_configuration);
            var accessToken       = "";

            try
            {
                var authTokenInfo = _apiClient.PostToken(ClientId, ClientSecret);
                accessToken = authTokenInfo.AccessToken;
                Console.WriteLine("Token received.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            _configuration.AccessToken = accessToken;

            try
            {
                var emailConv = await _conversationsApi.PostConversationsEmailsAsync(new CreateEmailRequest
                {
                    Direction = CreateEmailRequest.DirectionEnum.Outbound,
                    QueueId   = QueueId,
                    Priority  = 5,
                    ToAddress = "*****@*****.**",
                    ToName    = "Taras Buha",
                    Subject   = $"Re: Test Subj",
                    HtmlBody  = ">>API outbound email.",
                    Provider  = "PureCloud Email"
                });

                Console.WriteLine($"New email conv {emailConv.Id} was created.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.ReadLine();
        }
コード例 #7
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtClientId.Text) || string.IsNullOrEmpty(txtClientSecret.Text))
                {
                    MessageBox.Show("Enter a client id & secret first.");
                    return;
                }

                // Connect to PureCloud
                AddLog("Connecting...");
                Configuration.Default.ApiClient.RestClient.BaseUrl = new Uri($"https://api.{cmbEnvironment.SelectedItem.ToString()}");
                var accessTokenInfo = Configuration.Default.ApiClient.PostToken(txtClientId.Text, txtClientSecret.Text);
                Configuration.Default.AccessToken = accessTokenInfo.AccessToken;
                loggedIn = true;
                AddLog("Connected!");
                AddLog($"Access Token: {accessTokenInfo.AccessToken}", true);

                // Get APIs
                AddLog("Initializing APIs...", true);
                tokensApi        = new TokensApi();
                routingApi       = new RoutingApi();
                analyticsApi     = new AnalyticsApi();
                conversationsApi = new ConversationsApi();
                AddLog("Finished initializing APIs...", true);

                // Update Controls
                btnConnect.Enabled    = false;
                btnDisconnect.Enabled = true;
                gbQueues.Enabled      = true;

                // Populate Queues
                GetQueues();
            }
            catch (Exception ex)
            {
                AddLog($"Error in btnConnect_Click: {ex.Message}");
                AddLog($"Detailled error: {ex}", true);
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnConnect.Enabled    = true;
                btnDisconnect.Enabled = false;
                gbQueues.Enabled      = false;
                loggedIn = false;
            }
        }
コード例 #8
0
        private void HangUpButton_Click(object sender, EventArgs e)
        {
            try
            {
                var    api                   = new ConversationsApi();
                string conversationId        = conversationIdTextBox.Text;
                string participantId         = "";
                MediaParticipantRequest body = new MediaParticipantRequest();
                body.State = MediaParticipantRequest.StateEnum.Disconnected;

                api.PatchConversationsCallParticipant(conversationId, participantId, body);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #9
0
        private void CallButton_Click(object sender, EventArgs e)
        {
            try
            {
                var api = new ConversationsApi();

                CreateCallRequest body = new CreateCallRequest();
                body.PhoneNumber = "+6285221675710";

                CreateCallResponse result = api.PostConversationsCalls(body);
                conversationIdTextBox.Text = result.ToJson();
                conversationIdTextBox.Text = result.Id;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #10
0
        static void Main(string[] args)
        {
            // OAuth input
            Console.Write("Enter Client ID: ");
            string clientId = Console.ReadLine();

            Console.Write("Enter Client Secret: ");
            string clientSecret = Console.ReadLine();

            // Get the Date Interval
            Console.Write("Enter Date Interval (YYYY-MM-DDThh:mm:ss/YYYY-MM-DDThh:mm:ss): ");
            string interval = Console.ReadLine();

            Console.WriteLine("Working...");

            // Configure SDK Settings
            string accessToken = GetToken(clientId, clientSecret);

            PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;

            // Instantiate APIs
            ConversationsApi conversationsApi = new ConversationsApi();

            // Create folder that will store all the downloaded recordings
            string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            path = path.Substring(0, path.LastIndexOf("bin"));
            System.IO.Directory.CreateDirectory(path + "\\Recordings");

            // Call conversation API, pass date inputted to extract conversationIds needed
            AnalyticsConversationQueryResponse conversationDetails = conversationsApi.PostAnalyticsConversationsDetailsQuery(new ConversationQuery(Interval: interval));

            // Pass conversation details to function
            extractConversationDetails(conversationDetails);

            // Final Output
            Console.WriteLine("DONE");

            if (Debugger.IsAttached)
            {
                Console.ReadKey();
            }
        }
コード例 #11
0
        static void Main(string[] args)
        {
// >> START sms-notification-step-1
            // OAuth Credentials
            string clientId     = Environment.GetEnvironmentVariable("GENESYS_CLOUD_CLIENT_ID");
            string clientSecret = Environment.GetEnvironmentVariable("GENESYS_CLOUD_CLIENT_SECRET");
            // orgRegion value example: us_east_1
            string orgRegion = Environment.GetEnvironmentVariable("GENESYS_CLOUD_REGION");

            // Set Region
            PureCloudRegionHosts region = Enum.Parse <PureCloudRegionHosts>(orgRegion);

            Configuration.Default.ApiClient.setBasePath(region);
// >> END sms-notification-step-1

// >> START sms-notification-step-2
            // Configure SDK Settings
            var    accessTokenInfo = Configuration.Default.ApiClient.PostToken(clientId, clientSecret);
            string accessToken     = accessTokenInfo.AccessToken;

            PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;
// >> END sms-notification-step-2

// >> START sms-notification-step-3
            // Instantiate APIs
            ConversationsApi conversationsApi = new ConversationsApi();

            // Build request body
            SendAgentlessOutboundMessageRequest request = new SendAgentlessOutboundMessageRequest();

            request.FromAddress            = "+13178723000";
            request.ToAddress              = "+15557655942";
            request.ToAddressMessengerType = SendAgentlessOutboundMessageRequest.ToAddressMessengerTypeEnum.Sms;
            request.TextBody = "Hello, this is a test notification";

            // Call to PostConversationsMessagesAgentless function of Conversations API
            SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request);

            // Final Output
            Console.WriteLine(response.ToString());
// >> END sms-notification-step-3
        }
コード例 #12
0
        private void IVRButton_Click(object sender, EventArgs e)
        {
            try
            {
                var api = new ConversationsApi();

                string conversationId    = conversationIdTextBox.Text;
                string participantId     = participantIdTextbox.Text;
                CreateSecureSession body = new CreateSecureSession();
                body.FlowId              = "";
                body.UserData            = "<OrderID>|1000|" + conversationId + "|<Entity>";
                body.Disconnect          = false;
                body.SourceParticipantId = userIdTextbox.Text; // agentId

                SecureSession result = api.PostConversationParticipantSecureivrsessions(conversationId, participantId, body);
                IVRResultTextbox.Text = result.ToJson();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #13
0
        /// <summary>
        /// Get the conversation made within a specified duration. MediaType will be determined by media type of the first session in the conversation.
        /// </summary>
        /// <param name="interval"></param>
        /// <param name="api"></param>
        /// <returns></returns>
        private static Dictionary <string, AnalyticsSession.MediaTypeEnum> GetConversations(string interval, ConversationsApi api)
        {
            // Request the list of conversations
            List <AnalyticsConversation> conversations = api.PostAnalyticsConversationsDetailsQuery(new ConversationQuery(Interval: interval)).Conversations;

            // Dictionary to contain the conversations and media type
            Dictionary <string, AnalyticsSession.MediaTypeEnum> conversationsMap = new Dictionary <string, AnalyticsSession.MediaTypeEnum>();

            //Store the conversation IDs and the corresponding media type
            foreach (var conversation in conversations)
            {
                conversationsMap.Add(conversation.ConversationId, conversation.Participants.First().Sessions.First().MediaType.Value);
            }

            return(conversationsMap);
        }
コード例 #14
0
 public PureCloudService()
 {
     _conversationsApi = new ConversationsApi();
 }
コード例 #15
0
        private void ProcessVoicemail()
        {
            // Check Voicemail
            var vmApi   = new VoicemailApi();
            var convApi = new ConversationsApi();
            var vms     = vmApi.GetMessages();
            VoicemailMediaInfo vmMedia;

            foreach (VoicemailMessage vm in vms.Entities.Where(x => !(x.Read ?? false)))        // Unread VMs only
            {
                DateTime vmDate = vm.CreatedDate != null ? ((DateTime)vm.CreatedDate).ToLocalTime() : DateTime.Now;

                Log("VM from " + vm.CallerAddress + " at " + vmDate);

                // Check for Group attribute so we know where to send it (use default if nothing found)
                string group      = "unknown";
                string groupEmail = DefaultRecipientEmail;
                var    call       = convApi.GetCallsCallId(vm.Conversation.Id);

                CallMediaParticipant participant = null;
                try
                {
                    participant = call.Participants.First(x => x.Attributes != null && x.Attributes.ContainsKey("Group"));
                }
                catch { }

                if (participant != null)
                {
                    group = participant.Attributes["Group"];

                    // Try to look up the email for this group in Settings. If it's not found, just move on with the default
                    try
                    {
                        groupEmail = Properties.Settings.Default[group].ToString();
                    }
                    catch { }
                }
                else
                {
                    participant = call.Participants[0];
                }

                // Download the WAV file
                string fileName;
                vmMedia = vmApi.GetMessagesMessageIdMedia(vm.Id, "WAV");
                using (var client = new WebClient())
                {
                    fileName = Path.GetTempPath() +
                               "PureCloud_VM_" + group + "_" +
                               vmDate.ToString("yyyyMMdd-HHmmss") + ".wav";

                    client.DownloadFile(vmMedia.MediaFileUri, fileName);
                }

                // Email to the proper group
                string callerName = (vm.CallerName ?? participant.Name ?? vm.CallerAddress);
                string subject    = "Voicemail from " + callerName;
                string body       = ComposeVoicemailEmail(vmDate, group, vm.CallerAddress, callerName);
                SendEmail(groupEmail, EmailFromAddress, body, subject, fileName);
                Log("    Sent to " + group + ": " + groupEmail);

                // Mark the VM as read so it won't get sent again next time
                vm.Read = true;
                vmApi.PutMessagesMessageId(vm.Id, vm);
            }
        }
コード例 #16
0
 public void Init()
 {
     instance = new ConversationsApi();
 }
コード例 #17
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtClientId.Text) || string.IsNullOrEmpty(txtClientSecret.Text))
                {
                    MessageBox.Show("Enter a client id & secret first.");
                    return;
                }

                // Connect to PureCloud
                AddLog("Connecting...");
                Configuration.Default.ApiClient.RestClient.BaseUrl = new Uri($"https://api.{cmbEnvironment.SelectedItem.ToString()}");
                var accessTokenInfo = Configuration.Default.ApiClient.PostToken(txtClientId.Text, txtClientSecret.Text);
                Configuration.Default.AccessToken = accessTokenInfo.AccessToken;
                loggedIn = true;
                AddLog($"Connected.");
                AddLog($"Access Token: {accessTokenInfo.AccessToken}", true);

                // Get APIs
                AddLog("Initializing APIs...", true);
                analyticsApi              = new AnalyticsApi();
                routingApi                = new RoutingApi();
                conversationsApi          = new ConversationsApi();
                tokensApi                 = new TokensApi();
                telephonyProvidersEdgeApi = new TelephonyProvidersEdgeApi();
                AddLog("Finished initializing APIs...", true);

                // Update Controls
                btnConnect.Enabled        = false;
                btnDisconnect.Enabled     = true;
                gbEdges.Enabled           = true;
                gbTroubleshooting.Enabled = true;
                gbAgents.Enabled          = true;
                gbTestGhostCall.Enabled   = true;
                gbCounters.Enabled        = true;

                // Populate Edges
                GetEdges();

                // Get Agents Stats
                AddLog("Starting timer for monitoring agent status", true);
                PullAgentsData();
                timer.Interval = 5000;
                timer.Tick    += (object timerSender, EventArgs eventArgs) => { PullAgentsData(); };
                timer.Start();
                AddLog("Timer started", true);
            }
            catch (Exception ex)
            {
                AddLog($"Error in btnConnect_Click: {ex.Message}");
                AddLog($"Detailled error: {ex}", true);
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnConnect.Enabled        = true;
                btnDisconnect.Enabled     = false;
                gbEdges.Enabled           = false;
                gbTroubleshooting.Enabled = false;
                gbAgents.Enabled          = false;
                gbTestGhostCall.Enabled   = false;
                gbCounters.Enabled        = false;
                loggedIn = false;
            }
        }