[Bot在使用DirectLine频道时重复用户消息

问题描述 投票:1回答:1

我正在使用bot框架v4。我已经使用.Net Core开发了一个聊天机器人。该机器人与LUISQna Maker集成在一起。我面临的一个问题是,该漫游器复制了来自用户的消息。请查看以下屏幕截图:

enter image description here

我从漫游器中得到的回复非常好。机器人的流程符合预期。我只是不知道为什么来自用户的消息被重复。我为此使用DirectLine。我将分享所需的任何代码部分。

{
  "activities": [
    {
      "type": "message",
      "id": "BR1wBZw7w2852JMLobk0EC-o|0000000",
      "timestamp": "2019-12-02T19:41:57.1284328Z",
      "channelId": "directline",
      "from": {
        "id": "CivicDevBot",
        "name": "CivicChat"
      },
      "conversation": {
        "id": "BR1wBZw7w2852JMLobk0EC-o"
      },
      "attachments": [
        {
          "contentType": "application/vnd.microsoft.card.adaptive",
          "content": {
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [
              {
                "type": "Container",
                "items": [
                  {
                    "type": "ColumnSet",
                    "columns": [
                      {
                        "type": "Column",
                        "width": "auto",
                        "items": [
                          {
                            "type": "Image",
                            "size": "large",
                            "url": "https://i.imgur.com/ViaEUnA.png"
                          }
                        ]
                      }
                    ],
                    "horizontalAlignment": "Center"
                  },
                  {
                    "type": "ColumnSet",
                    "columns": [
                      {
                        "type": "Column",
                        "width": "auto",
                        "items": [
                          {
                            "type": "TextBlock",
                            "size": "large",
                            "weight": "bolder",
                            "color": "light",
                            "text": "Welcome to CIVIC Financial Services",
                            "wrap": true
                          },
                          {
                            "type": "TextBlock",
                            "size": "large",
                            "weight": "bolder",
                            "color": "light",
                            "text": "I am S.U.E",
                            "wrap": true
                          },
                          {
                            "type": "TextBlock",
                            "color": "light",
                            "text": "I can help you answer your questions. Familiarize yourself with CIVIC Financial Services.",
                            "wrap": true
                          },
                          {
                            "type": "TextBlock",
                            "color": "light",
                            "text": "If you want to talk to a Customer Service Agent, just type \"I want to talk to a Customer Service Agent\".",
                            "wrap": true
                          }
                        ],
                        "separator": true,
                        "horizontalAlignment": "Left"
                      }
                    ]
                  }
                ]
              }
            ],
            "actions": [
              {
                "type": "Action.Submit",
                "data": {
                  "action": "aboutCivic"
                },
                "title": "About CIVIC"
              },
              {
                "type": "Action.ShowCard",
                "card": {
                  "type": "AdaptiveCard",
                  "actions": [
                    {
                      "type": "Action.ShowCard",
                      "card": {
                        "type": "AdaptiveCard",
                        "body": [
                          {
                            "type": "TextBlock",
                            "text": "We are open from Monday through Friday from 8:00am to 6:00pm.",
                            "wrap": true
                          }
                        ],
                        "style": "emphasis"
                      },
                      "title": "When are you open?"
                    },
                    {
                      "type": "Action.ShowCard",
                      "card": {
                        "type": "AdaptiveCard",
                        "body": [
                          {
                            "type": "Image",
                            "size": "stretch",
                            "url": "https://i.imgur.com/gBVgI25.png",
                            "horizontalAlignment": "center"
                          },
                          {
                            "type": "TextBlock",
                            "text": "AZ, CA, CO, FL, GA, HI, NC, NV, OR, SC, TN, TX, UT, VA & WA",
                            "wrap": true
                          }
                        ],
                        "style": "emphasis"
                      },
                      "title": "Do you have an office near me? "
                    },
                    {
                      "type": "Action.ShowCard",
                      "card": {
                        "type": "AdaptiveCard",
                        "body": [
                          {
                            "type": "TextBlock",
                            "text": "8 to 10 days, it all depends on how it takes to get access to the property.",
                            "wrap": true
                          }
                        ],
                        "style": "emphasis"
                      },
                      "title": "How quickly can we close? "
                    }
                  ],
                  "style": "emphasis"
                },
                "title": "FAQs"
              }
            ]
          }
        }
      ],
      "entities": [],
      "replyToId": "8WGOnspSxN3"
    },
    {
      "type": "message",
      "id": "BR1wBZw7w2852JMLobk0EC-o|0000001",
      "timestamp": "2019-12-02T19:43:39.96502Z",
      "serviceUrl": "https://directline.botframework.com/",
      "channelId": "directline",
      "from": {
        "id": "r_1575315715",
        "name": "",
        "role": "user"
      },
      "conversation": {
        "id": "BR1wBZw7w2852JMLobk0EC-o"
      },
      "textFormat": "plain",
      "locale": "en-GB",
      "text": "teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "entities": [
        {
          "type": "ClientCapabilities",
          "requiresBotState": true,
          "supportsListening": true,
          "supportsTts": true
        }
      ],
      "channelData": {
        "siteDomain": "https://websiteae1.stackblitz.io/"
      }
    },
    {
      "type": "message",
      "id": "BR1wBZw7w2852JMLobk0EC-o|0000002",
      "timestamp": "2019-12-02T19:43:41.7278914Z",
      "channelId": "directline",
      "from": {
        "id": "CivicDevBot",
        "name": "CivicChat"
      },
      "conversation": {
        "id": "BR1wBZw7w2852JMLobk0EC-o"
      },
      "text": "Sorry, I didn't understand. Consider rephrasing your question or contacting a customer agent",
      "attachments": [],
      "entities": [],
      "replyToId": "BR1wBZw7w2852JMLobk0EC-o|0000001"
    },
    {
      "type": "message",
      "id": "BR1wBZw7w2852JMLobk0EC-o|0000003",
      "timestamp": "2019-12-02T20:00:25.784598Z",
      "serviceUrl": "https://directline.botframework.com/",
      "channelId": "directline",
      "from": {
        "id": "r_1575315715",
        "name": "",
        "role": "user"
      },
      "conversation": {
        "id": "BR1wBZw7w2852JMLobk0EC-o"
      },
      "textFormat": "plain",
      "locale": "en-GB",
      "text": "helo",
      "channelData": {
        "siteDomain": "https://websiteae1.stackblitz.io/"
      }
    },
    {
      "type": "message",
      "id": "BR1wBZw7w2852JMLobk0EC-o|0000004",
      "timestamp": "2019-12-02T20:00:26.5739342Z",
      "channelId": "directline",
      "from": {
        "id": "CivicDevBot",
        "name": "CivicChat"
      },
      "conversation": {
        "id": "BR1wBZw7w2852JMLobk0EC-o"
      },
      "text": "Sorry, I didn't understand. Consider rephrasing your question or contacting a customer agent",
      "attachments": [],
      "entities": [],
      "replyToId": "BR1wBZw7w2852JMLobk0EC-o|0000003"
    },
    {
      "type": "message",
      "id": "BR1wBZw7w2852JMLobk0EC-o|0000005",
      "timestamp": "2019-12-02T20:00:27.3293896Z",
      "serviceUrl": "https://directline.botframework.com/",
      "channelId": "directline",
      "from": {
        "id": "r_1575315715",
        "name": "",
        "role": "user"
      },
      "conversation": {
        "id": "BR1wBZw7w2852JMLobk0EC-o"
      },
      "textFormat": "plain",
      "locale": "en-GB",
      "text": "hello",
      "channelData": {
        "siteDomain": "https://websiteae1.stackblitz.io/"
      }
    },
    {
      "type": "message",
      "id": "BR1wBZw7w2852JMLobk0EC-o|0000006",
      "timestamp": "2019-12-02T20:00:27.6064185Z",
      "channelId": "directline",
      "from": {
        "id": "CivicDevBot",
        "name": "CivicChat"
      },
      "conversation": {
        "id": "BR1wBZw7w2852JMLobk0EC-o"
      },
      "text": "Hello",
      "inputHint": "acceptingInput",
      "attachments": [],
      "entities": [],
      "replyToId": "BR1wBZw7w2852JMLobk0EC-o|0000005"
    }
  ],
  "watermark": "6"
}
asp.net-core botframework chatbot azure-bot-service direct-line-botframework
1个回答
0
投票

有人解决了这个问题吗?

这是我的代码:

  var d1 = window.WebChat.createDirectLine({ token: '@Model.directLineToken.token' });
        window.WebChat.renderWebChat({
            directLine: Object.assign({}, d1, {
                postActivity: activity => {
                    var newActivity = Object.assign({}, activity, { channelData: { "param1": "test", "userLevel": "1" } });
                    return d1.postActivity(newActivity);
                }
            }),
            store,
            userID: '@Model.chatConfig.UserId',
            styleOptions
        },
            document.getElementById('webchat')
        );

令牌和UserId是服务器端由:

https://directline.botframework.com/v3/directline/tokens/generate

var userId = $"dl_{Guid.NewGuid()}";

并放入模型中

© www.soinside.com 2019 - 2024. All rights reserved.