测试自定义消息传递通道

通过适用于客户服务的 Omnichannel,可以实现连接器来集成自定义消息传送通道。 完整的 示例代码 演示了如何使用 Direct Line 机器人创建自己的连接器,以便与客户服务全渠道集成。

用于测试自定义消息传递通道的示例代码

可以使用以下示例代码测试要引入到 Customer Service 全渠道的自定义消息通道。 可以修改示例代码以满足组织的需求。

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Web Chat: Full-featured bundle</title>

    <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>

    <style>
    html, body { height: 100% }
    body {
      margin: 0;
      background-color: paleturquoise;
    }
    #webchat {
      height: 100%;
      width: 100%;
    }
  </style>
</head>
<body>
       <div id="webchat" role="main"></div>
    <script>
    (async function () {
        const res = await fetch('https://directline.botframework.com/v3/directline/conversations', 
{ method: 'POST', headers: { Authorization: 'Bearer ***************Insert Direct Line Secret here *******************' }});

      const { token } = await res.json();

      (async function () {
	window.WebChat.renderWebChat({
      directLine: window.WebChat.createDirectLine({ token }),
      styleOptions: {
        rootHeight: '100%',
        rootWidth: '50%',
		bubbleMaxWidth: 1200,               
        botAvatarInitials: 'C',                
        userAvatarInitials: 'A',  
      }
    }, document.getElementById('webchat'));
    })()
    })().catch(err => console.error(err));
   </script>
</body>
</html>

后续步骤

Direct Line API 3.0 中的关键概念

使用 Direct Line 自带自定义通道
配置自定义消息渠道