0

我正在尝试使用 Amazon 连接流 API 在 React TS 中创建 AgentChat 面板并连接聊天 JS 根据我需要导入的https://github.com/amazon-connect/amazon-connect-chatjs和 amazon-connect-streams API 文档流和 chatjs 库按顺序排列。我正在导入streamsJS,然后是chatJS,但'getMediaController'仍然会引发错误。

我确实检查了https://github.com/amazon-connect/amazon-connect-streams/issues/197这个,仍然缺少一些东西

import "amazon-connect-streams";
import "amazon-connect-chatjs";
import { CCP_URL } from "../Constants";
export default class ContactCenter {
  constructor() {
    try {
      var containerDiv = document.getElementById("ccpContainer");
      this.connect.core.initCCP(containerDiv as HTMLElement, {
        ccpUrl: CCP_URL,
        loginPopup: true,
        loginPopupAutoClose: true,
        loginOptions: {
          autoClose: true,
        },
        softphone: {
          allowFramedSoftphone: true,
          disableRingtone: false, 
        },
      });      
      connect.contact(function (contact) {
        const c = contact;
        if (contact.getType() !== connect.ContactType.CHAT) {
          return;
        }
        c.onConnecting(function (c) {
          console.log("incoming");
          c.accept();
        });
        c.onAccepted(async () => {
          const cnn = contact.getConnections().find(cnn => cnn.getType() === connect.ConnectionType.AGENT);
          if(cnn){
          const agentChatSession = await cnn.getMediaController();
          console.log(cnn)
          }
        });
      });
      return this.connect;
    } catch (error) {
      console.log(error);
      return;
    }
  }
}

收到以下错误。

Property 'getMediaController' does not exist on type 'BaseConnection'.  TS2339

    33 |           const cnn = contact.getConnections().find(cnn => cnn.getType() === connect.ConnectionType.AGENT);
    34 |           if(cnn){
  > 35 |           const agentChatSession = await cnn.getMediaController();
       |                                              ^
    36 |           console.log(agentChatSession)
    37 |           }
    38 |         });

请帮帮我,我错过了什么。

4

1 回答 1

0

没关系,修好了。

instead of const cnn = contact.getConnections().find(cnn => cnn.getType() === connect.ConnectionType.AGENT);

added

const cnn = c.getAgentConnection() as connect.ChatConnection
于 2021-09-14T07:41:21.103 回答