首页 > 解决方案 > 如何使用节点 js 使用 botbulilder webex 适配器将 MS Bot 与 Webex 团队集成

问题描述

我正在尝试使用 botbuilder webex 适配器将在节点 js 中开发的 MS Bot 与 webex 团队集成,如下所示

//creating webex adapter for bot channel
const adapter = new WebexAdapter({
access_token: process.env.ACCESS_TOKEN,
public_address: process.env.PUBLIC_ADDRESS,
secret: process.env.SECRET });

尝试运行时,我收到此警告 消息 需要一些解决方案。

标签: node.jsbotframeworkwebex

解决方案


您收到此错误是因为标题中的签名与您的秘密哈希不匹配。这是引发此错误的代码的相关部分。

if (this.options.secret) {
   const signature = req.headers['x-spark-signature'];
   const hash = crypto.createHmac('sha1', this.options.secret).update(JSON.stringify(payload)).digest('hex');
   if (signature !== hash) {
      console.warn('WARNING: Webhook received message with invalid signature. Potential malicious behavior!');
      return false;
   }
}

您需要检查请求标头中的签名是否正确,并且您在机器人选项中设置了正确的密码。

Github 上的参考资料:https ://github.com/howdyai/botkit/blob/master/packages/botbuilder-adapter-webex/src/webex_adapter.ts


推荐阅读