首页 > 解决方案 > 在 Azure Bot 上查看以前的用户消息

问题描述

如何在 Azure Bot 服务中显示以前的用户消息?我从数据库中获取它们,我可以在我的控制台上打印它们。假设我有来自用户 1 的消息 U1 和 B1 机器人对此消息的回复。如何让机器人发送 U1?

每当我尝试发送 U1 和 B1 时,都会作为机器人消息发送出去。我正在使用 Microsoft Azure 机器人。

编辑 1:我在 Node.js 中尝试了 sendConversationHistory() 方法,它工作正常。我能够在机器人模拟器 v4 上查看消息。但是,当相同的代码用于部署时,它会显示错误的活动。有人可以在这里帮助我吗?

在此处输入图像描述

部署错误消息:

Error: Invalid activities
at new RestError (D:\home\site\wwwroot\node_modules\@azure\ms-rest-js\lib\restError.ts:18:5)
at D:\home\site\wwwroot\node_modules\@azure\ms-rest-js\lib\policies\deserializationPolicy.ts:117:27
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7),code: 'BadSyntax',statusCode: 400,

正在发送的活动具有以下代码中提到的形式:

const newLocal = [{
    type: 'message', text: 'User message', from: context.activity.from, localTimezone: 'America/Los_Angeles', serviceUrl: context.activity.serviceUrl,
    channelId: context.activity.channelId, callerId: 'abc', recipient: context.activity.recipient, label: 'test', valueType: 'test', listenFor: ['nothing'],
    conversation: { isGroup: false, conversationType: 'test', tenantId: 'abc', id: context.activity.from.id, name: context.activity.from.name, message: 'User message' }
  },
  {
    type: 'message', text: 'Bot message!', from: context.activity.recipient, localTimezone: 'America/Los_Angeles', serviceUrl: context.activity.serviceUrl,
    channelId: context.activity.channelId, callerId: 'abc', recipient: context.activity.from, label: 'test', valueType: 'test', listenFor: ['nothing'],
    conversation: { isGroup: false, conversationType: 'test', tenantId: 'abc', id: context.activity.from.id, name: context.activity.from.name, message: 'Botmessage' }
  }
  ];

我的问题是它在模拟器上测试时是否正常工作,为什么它在部署时显示不良活动?

标签: botframeworkbotsazure-bot-servicedirect-line-botframework

解决方案


推荐阅读