【问题标题】:Microsoft Bot Framework[MigrationV3V4] throws 500 Internal Server Error on endOfConversationMicrosoft Bot Framework[MigrationV3V4] 在 endOfConversation 上引发 500 内部服务器错误
【发布时间】:2021-05-19 21:46:30
【问题描述】:

一些背景

我正在关注this Microsoft 文档示例,以了解如何将 v3 机器人转换为技能并从 v4 机器人使用它。(文档中 Git Repo 的链接似乎已损坏,使用下面的正确链接)

按照文档中的说明,我克隆了 v3-skill-botv3-booking-bot-skillv4-root-bot,并且几乎所有东西都在我的本地正常工作。

问题

但是当 v3 技能机器人调用 session.endConversation() 时,我在 v3 代码中收到了一个 Internal Server ErrorendOfConversation 活动在 v4 机器人中被正确捕获,所有操作都按预期正确执行。

除了更新 .env 文件外,我不会以任何方式修改克隆代码。 据我所知,在 v3 Bot 中抛出的 Internal Server Error 并没有以任何方式破坏流程。

不过,我不确定为什么会抛出这个问题,如果有人可以提供解决方案,那就太好了。

一些有用的sn-ps代码

粘贴相关代码的 sn-ps。(这完全是从 git repo 复制的)

v4-root-bot/rootBot.js 中,在 v3 代码中调用 endConversation() 时会正确捕获 onEndOfConversation 事件。

this.onEndOfConversation(async (context, next) => {
    // Stop forwarding activities to Skill.
    await this.activeSkillProperty.set(context, undefined);

    // Show status message, text and value returned by the skill
    let eocActivityMessage = `Received ${ ActivityTypes.EndOfConversation }.\n\nCode: ${ context.activity.code }`;
    if (context.activity.text) {
        eocActivityMessage += `\n\nText: ${ context.activity.text }`;
    }

    if (context.activity.value) {
        eocActivityMessage += `\n\nValue: ${ JSON.stringify(context.activity.value) }`;
    }

    await context.sendActivity(eocActivityMessage);

    // We are back at the root
    const card = this.getOptionsCard();
    const message = MessageFactory.attachment(card);
    await context.sendActivity(message);

    // Save conversation state
    await this.conversationState.saveChanges(context, true);

    // By calling next() you ensure that the next BotHandler is run.
    await next();
});

在 v3 Skill bot v3-skill-bot/app.js on session.endConversation() 中,抛出 500 Internal Server

const bot = new builder.UniversalBot(connector, function (session) {
switch (session.message.text.toLowerCase()) {
    case 'end':
    case 'stop':
        session.endConversation();
        break;
    default:
        session.send("Echo (JS V3) You said: %s", session.message.text);
        session.send('Say "end" or "stop" and I\'ll end the conversation and back to the parent.');
}
}).set('storage', inMemoryStorage); 

v3 Skill bot 中引发的内部服务器错误示例

Error: POST to 'http://localhost:3978/api/skills/v3/conversations/emulator%3Aafa14650-acf1-11eb-8367-4f0cff212aa0%7Clivechat/activities/c189ee30-acf1-11eb-873e-0f26fb88a562' failed: [500] Internal Server Error
    at Request._callback (/Users/prabhu/Code/BotBuilder-Samples-main/MigrationV3V4/Node/Skills/v3-booking-bot-skill/node_modules/botbuilder/lib/bots/ChatConnector.js:722:46)
    at Request.self.callback (/Users/prabhu/Code/BotBuilder-Samples-main/MigrationV3V4/Node/Skills/v3-booking-bot-skill/node_modules/request/request.js:185:22)
    at Request.emit (events.js:314:20)
    at Request.<anonymous> (/Users/prabhu/Code/BotBuilder-Samples-main/MigrationV3V4/Node/Skills/v3-booking-bot-skill/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:314:20)
    at IncomingMessage.<anonymous> (/Users/prabhu/Code/BotBuilder-Samples-main/MigrationV3V4/Node/Skills/v3-booking-bot-skill/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:420:28)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

1 天后更新

我设法找出问题的根本原因,但仍然没有解决办法。

v4-root-bot/skillConversationIdFactory.js

async deleteConversationReference(skillConversationId) {
    // if the blow line is commented, I am not getting any error
    //this.refs[skillConversationId] = undefined;
}

【问题讨论】:

    标签: botframework


    【解决方案1】:

    仅当从模拟器连接到父级时才会出现此问题。

    我在 BotBuilder-Samples Git Repo 中将此作为问题提出。 Issue # 3240。阅读那里的 cmets 以了解更多信息。

    解决方法是只注释掉下面提到的行或覆盖 v3 以在结束对话后不发送跟踪。

    async deleteConversationReference(skillConversationId) {
        // if the blow line is commented, I am not getting any error
        //this.refs[skillConversationId] = undefined;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-09
      相关资源
      最近更新 更多