简体   繁体   English

MS Bot Framework 专线 API 3.0: Get starting message

[英]MS Bot Framework Direct Line API 3.0: Get starting message

I published a bot using the Azure bot framework to the Azure cloud servers, and made an application that uses the Direct Line API 3.0 to send user responses and receive bot messages through HTTP requests.我使用 Azure bot 框架发布了一个 bot 到 Azure 云服务器,并制作了一个应用程序,使用Direct Line API 3.0通过 HTTP 请求发送用户响应和接收 bot 消息。 Everything works except that I'm not sure how to get the starting message of the bot at the start of the conversation.一切正常,只是我不确定如何在对话开始时获取机器人的起始消息。 I open the conversation with the /v3/directline/conversations endpoint, but I'm not sure how to receive the first message of the bot (that is normally sent without any user interaction).我使用/v3/directline/conversations端点打开对话,但我不确定如何接收机器人的第一条消息(通常在没有任何用户交互的情况下发送)。 A message request after opening the conversation doesn't include any bot responses, but the next message request after sending the first user input includes the first two messages of the bot (starting message and response to the user).打开对话后的消息请求不包含任何机器人响应,但发送第一个用户输入后的下一个消息请求包含机器人的前两条消息(开始消息和对用户的响应)。

EDIT: From reading this I came to the conclusion that it will be easier to just use a custom event as a trigger for the welcome message.编辑:通过阅读这篇文章,我得出的结论是,将自定义事件用作欢迎消息的触发器会更容易。 I updated my bot as follows to reflect this within bot composer, adding a new CUSTOM event trigger with a test response message:我按如下方式更新了我的 bot,以在 bot composer 中反映这一点,添加了一个带有测试响应消息的新 CUSTOM 事件触发器:

在此处输入图像描述

However, I still can't seem to trigger this event via the Direct Line API. Currently, I send a request as follows, following the event activity structure :但是,我似乎仍然无法通过直线 API 触发此事件。目前,我按照事件活动结构发送请求如下:

{ 
  "type": "event", 
  "channelId": "directline", 
  "from": { "id": "UnityUserId", "name": "Unity User 1" }, 
  "value": "test", 
  "name": "welcome" 
}

I then get a response with ID, normally indicating that the request was successfull.然后我收到一个带有 ID 的响应,通常表示请求成功。 However, upon requesting the bot response messages, I get the following:但是,在请求机器人响应消息时,我得到以下信息:

{
  "activities": [
    {
      "type": "event",
      "id": "5FZsHpWBxm1hjhWQYY7gr-eu|0000000",
      "timestamp": "2022-04-09T14:39:15.90169Z",
      "serviceUrl": "https://directline.botframework.com/",
      "channelId": "directline",
      "from": {
        "id": "UnityUserId",
        "name": "Unity User 1"
      },
      "conversation": {
        "id": "5FZsHpWBxm1hjhWQYY7gr-eu"
      },
      "value": "test",
      "name": "welcome"
    }
  ],
  "watermark": "0"
}

Indicating that the bot has no responses, which doesn't seem quite right when looking at the bot composer screenshot above.表示机器人没有响应,在查看上面的机器人编辑器屏幕截图时,这似乎不太正确。 Is there something wrong with my current method?我现在的方法有问题吗?

Regards问候

I thought I remembered seeing the bot's welcome message when using Direct Line, so I tried to quickly repro it again.我想我记得在使用 Direct Line 时看到了机器人的欢迎消息,所以我再次尝试快速重现它。 I connected a simple echo bot via Direct Line.我通过 Direct Line 连接了一个简单的回声机器人。 Then I created a conversation, sent a simple message, and then retrieved all activities (all via REST calls), and the bot's welcome message was indeed present in the response, as you can see in this screenshot:然后我创建了一个对话,发送了一条简单的消息,然后检索了所有活动(全部通过 REST 调用),机器人的欢迎消息确实出现在响应中,如您在此屏幕截图中所见:

在此处输入图像描述

Perhaps you should use these Direct Line 3.0 API reference docs as opposed to the one you linked above.也许您应该使用这些 Direct Line 3.0 API 参考文档,而不是上面链接的参考文档。 I followed these steps using the basic Echo bot sample, Postman, and a bot resource in Azure for simple and easy testing, but you could use a full application if you wish.我使用基本的 Echo 机器人示例 Postman 和 Azure 中的机器人资源按照这些步骤进行简单易用的测试,但如果您愿意,您可以使用完整的应用程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 Amazon lex 与 MS Bot 框架集成? - How to integrate Amazon lex with MS Bot framework? slack bot 使用 aws 向用户发送直接消息 lambda function - slack bot sending direct message to user using aws lambda function 使用 MS Bot Framework 在 UserState/Azure Blob 存储上保存 JWT 是否安全? - Is it safe to save JWT on UserState/Azure Blob Storage with MS Bot Framework? Lambda 可以从直接调用和 SNS 消息中获取 arguments - Lambda that can get arguments from both direct invocation and SNS message 通过 powershell 命令禁用 azure bot 的直接线路连接通道中的增强型身份验证选项? - Disable Enchanced authentication options in Direct line connection channel of azure bot via powershell command? 如何在 API 中获取 PubSub 消息数据? - How to get PubSub message data in an API? Bot Framework LUIS 忽略特定单词 - Bot Framework LUIS ignore specific words 如何在 MS Graph API 中从 Java SDK 获取附件资源的原始内容? - How do I get the raw content of attachment resources from Java SDK in MS Graph API? 在 MS Bot Composer 中保存用户机器人对话和 Intent - Save user bot conversation along with Intent in MS Bot Composer 读取数据时出错,报错信息:CSV table references column position 174,但从position:136868开始的行只包含94列 - Error while reading data, error message: CSV table references column position 174, but line starting at position:136868 contains only 94 columns
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM