如何自动更改 Amazon Connect 上的代理状态?

How to automatically change agent status on Amazon Connect?

我需要有关如何将 CCP 加载到网页和使用流的分步说明 API。我需要 javascript 在 25 秒后将代理从 "missed" 变为 "available"。

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

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

If you're embedding the CCP and using the Streams API, you can check the agent status on refresh, and if it's in Missed Call, set it to Available. I have this set to happen after 10 seconds.

对于嵌入式 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);
    }
}

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

<!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>

您可以在此处 https://github.com/amazon-connect/amazon-connect-streams/blob/master/Documentation.md

查看 StreamsAPI 的文档