【问题标题】:Skype bot built with skype-sdk in Node.js is not running correctly?在 Node.js 中使用 Skype-sdk 构建的 Skype 机器人运行不正确?
【发布时间】:2016-10-03 10:48:33
【问题描述】:

我正在尝试构建 Skype 机器人。

我遵循skype-sdk 提供的文档,但未能使用它创建它。无法得到机器人的回复。

const fs = require('fs');
const restify = require('restify');
const skype = require('skype-sdk');

const botService = new skype.BotService({
    messaging: {
        botId: 'xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx',
        serverUrl : "https://example.net",
        requestTimeout : 15000,
        appId: 'xxxxxxxx-xxx-xxx-xxx-xxxxxxxxxxxx',
        appSecret: 'xxxxxxxxxxxxxxxxxxxxxxxx'
    }
});

botService.on('contactAdded', (bot, data) => {
    console.log("bot replay");
    bot.reply('Hello ${data.fromDisplayName}!', true);
});

botService.on('personalMessage', (bot, data) => {
    console.log("person replay");
    bot.reply('Hey ${data.from}. Thank you for your message: "${data.content}".', true);
});

const server = restify.createServer();

server.use(skype.ensureHttps(true));
server.use(skype.verifySkypeCert({}));

server.post('/skbot', skype.messagingHandler(botService));
const port = process.env.PORT || 8080;
server.listen(port);
console.log('Listening for incoming requests on port ' + port);

谢谢

【问题讨论】:

  • 看起来不错的教程。是什么让您认为这里的答案会更好?
  • 我的意思是,为什么你没有按照教程失败?教程出了什么问题,我们应该给你什么答案?
  • 无法得到机器人的回复
  • 不幸的是,我们不知道为什么在没有任何其他信息的情况下会发生这种情况。

标签: node.js bots skypedeveloper skype-bots


【解决方案1】:

在示例中,由于指定了错误的服务器,机器人未连接到 Skype 服务器:

serverUrl : "https://example.net"

您必须指定一个有效的 Skype 服务器:

serverUrl : "https://apis.skype.com"

您还在 server.post 中指定了错误的 API uri(实际上这取决于您的 webhook 设置,但未提供它们,所以我假设为默认值):

server.post('/skbot', skype.messagingHandler(botService));

您必须使用'/v1/chat' 发送消息。试试this tutorial

【讨论】:

  • appidbotid 相同,appSecretpassword 还是privatekey.. 在调试模式下我看到skype-sdk.azure-utils Request not received over HTTPS, redirecting to HTTPS endpoint
  • 它适用于我的 ngrok,但不能单独使用 https,我正在运行 apache 服务器。这会导致问题吗???
  • Apache 服务器?出于什么目的?你是什​​么意思“不工作”,究竟发生了什么?
  • 我建议您隔离问题并发布有关它的新问题。尝试更具体并描述所有细节。您现在要问的是“我做了一些事情,但它不起作用,告诉我为什么”。
【解决方案2】:

使用 Microsoft Bot Framework 的 BotBuilder SDK 构建您的机器人,而不是使用 skype-sdk 包。

您可以使用以下示例代码构建一个基本的 Skype 机器人:

https://github.com/Microsoft/BotBuilder/blob/master/Node/examples/demo-skype/app.js

有关 Skype 功能的更详细示例,请在此处查看我在 GitHub 上的 Skype 机器人示例:

https://github.com/nwhitmont/botframework-skype-support-dev/blob/master/server.js

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-07
    • 2016-10-20
    • 1970-01-01
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 2015-06-01
    • 2019-09-05
    相关资源
    最近更新 更多