4

我需要逐步指导如何将 CCP 加载到网页中并使用流 API。我需要 javascript 在 25 秒后将代理从“错过”变为“可用”。

目前我们必须手动更新状态,这对我们的用例没有意义。

我在 Amazon Connect 论坛上看到有人提到了一种自动将状态从 Missed 更改为 Available 的方法。

如果您要嵌入 CCP 并使用 Streams API,您可以在刷新时检查代理状态,如果处于未接来电状态,请将其设置为可用。我有这个设置在 10 秒后发生。

4

1 回答 1

3

对于嵌入式 CCP,您可以使用 Stream API 执行此操作。您可以订阅代理刷新状态,并在那里进行。

connect.agent(function (agent) {
    logInfoMsg("Subscribing to events for agent " + agent.getName());
    logInfoMsg("Agent is currently in status of " + agent.getStatus().name);
    agent.onRefresh(handleAgentRefresh);
}

function handleAgentRefresh(agent) {
    var status = agent.getStatus().name;
    logInfoEvent("[agent.onRefresh] Agent data refreshed. Agent status is " + status);

    //if status == Missed Call, 
    //    set it to Available after 25 seconds."
    //For example -but maybe this is not the best approach

    if (status == "Missed") { //PLEASE review if "Missed" and "Availble"  are proper codes
        setTimeout(function () {
            agent.setState("Available", {
                success: function () {
                    logInfoEvent(" Agent is now Available");
                },
                failure: function (err) { 
                    logInfoEvent("Couldn't change Agent status to Available. Maybe already in another call?");
                }
            });
            ;
        }, 25000);
    }
}

如果您还需要知道如何在网站中嵌入 CCP,您可以这样做

<!DOCTYPE html>
<meta charset="UTF-8">
<html>
  <head>
    <script type="text/javascript" src="amazon-connect-1.4.js"></script>
  </head>
  <!-- Add the call to init() as an onload so it will only run once the page is loaded -->
  <body onload="init()">
    <div id=containerDiv style="width: 400px;height: 800px;"></div>
    <script type="text/javascript">
      var instanceURL = "https://my-instance-domain.awsapps.com/connect/ccp-v2/";
      // initialise the streams api
      function init() {
        // initialize the ccp
        connect.core.initCCP(containerDiv, {
          ccpUrl: instanceURL,            // REQUIRED
          loginPopup: true,               // optional, defaults to `true`
          region: "eu-central-1",         // REQUIRED for `CHAT`, optional otherwise
          softphone: {                    // optional
            allowFramedSoftphone: true,   // optional
            disableRingtone: false,       // optional
            ringtoneUrl: "./ringtone.mp3" // optional
           }
         });
      }
    </script>
  </body>
</html>

您可以在此处查看 StreamsAPI 的文档https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md

于 2020-05-23T11:08:17.757 回答