使用 Direct Line(非网络聊天)托管在 LivePerson 中的 Microsoft Bot(使用框架 v4)未触发欢迎消息

时间:2021-03-03 15:15:18

标签: botframework direct-line-botframework liveperson

首先,在 WebChat 的上下文中已经有很多关于这个主题的文章,并且有显示实现的修复程序。这是一个非常好的链接:

这个问题不是网络聊天问题,而是一个 Direct Line 问题,它使用名为 LivePerson 的第 3 方托管位于 Azure 中的机器人,并通过 Direct Line 连接。因此,我不控制客户端代码(就像我使用 html/JavaScript 编写/托管机器人一样)。然而,这里的要点是“不要使用对话更新”,我在我的机器人中使用它,但请继续阅读...

我使用 Direct Line 在 LivePerson 中托管我的 Microsoft v4 Bot。机器人使用自适应对话框欢迎用户并在用户使用 OnConversationUpdateActivity() 发送任何输入之前向他们提问:

public RootDialog(IConfiguration configuration, IMiddlewareApiFacade middlewareApi, IBotTelemetryClient telemetryClient) : base(nameof(RootDialog))
{
    var rootDialog = new AdaptiveDialog(nameof(RootDialog))
    {
        ...
        Triggers = new List<OnCondition>()
            new OnConversationUpdateActivity()
            {
                Actions = WelcomeUserSteps("${Greeting()}")
            }
            ...
    }
    
    private static List<Dialog> WelcomeUserSteps(string message)
        {
            return new List<Dialog>()
            {
                // Iterate through membersAdded list and greet user added to the conversation.
                new Foreach()
                {
                    ItemsProperty = "turn.activity.membersAdded",
                    Actions = new List<Dialog>()
                    {
                        // Note: Some channels send two conversation update events - one for the Bot added to the conversation and another for user.
                        // Filter cases where the bot itself is the recipient of the message. 
                        new IfCondition()
                        {
                            Condition = "$foreach.value.name != turn.activity.recipient.name",
                            Actions = new List<Dialog>()
                            {
                                new SendActivity(message),
                                new BeginDialog(nameof(WelcomeDialog))
                            }
                        }
                    }
                }
            };
        }
    }
}

当使用模拟器在本地运行机器人或从 Azure 中的测试网络聊天运行机器人时,这可以正常工作,但在 LivePerson 中不起作用。

我已成功连接并测试了 LivePerson 通过 Direct Line 与机器人的连接: enter image description here

但是,当机器人启动并通过 LivePerson 的聊天访问它时,欢迎消息不会触发(应该有欢迎消息,然后是机器人发出的红色方块所在位置的问题): enter image description here

查看 LivePerson 的文档,他们有一个 "The Welcome Event" 部分,其中讨论了机器人向用户问候配置为“聊天”的机器人(这是在 LivePerson 中配置此机器人的方式)

仔细查看聊天对话机器人如何开始聊天,文档指出:

<块引用>

当聊天被路由到代理时,聊天对话被视为开始。最佳做法是让代理提供第一个响应。在这种情况下,没有来自消费者的文本要解析,因此默认的“WELCOME”事件被用作机器人的起点,以提示用户提供输入并推进对话。 确保您的机器人中有一个“入口点”,可以响应新聊天客户发送的默认“欢迎”操作。

那么这段代码:

{
  // ...
  "type": "message",
  "text": "",
  "channelData": {
    "action": {
      "name": "WELCOME"
    }
  }
}

仅供参考:LivePerson 上下文中的“代理”可以指真实的人或机器人。两者都被视为“代理”,当您向 LivePerson 添加新代理时,可用类型之一是“bot”。所以在这个例子中,agent 不是指人。

我不太确定我的机器人(它使用机器人框架 v4 和自适应对话框)需要如何配置/实现以具有响应此 WELCOME 消息的入口点。

我知道我不能使用conversationUpdate(或在自适应对话中,OnConversationUpdateActivity()),但我不太确定我需要使用哪个自适应对话(或其他)以某种方式拦截要发送到的json WELCOME消息LivePerson 的我的机器人... OnEventActivity()? OnMessageActivity()?还有什么?

谢谢!

1 个答案:

答案 0 :(得分:0)