Azure机器人程序框架-直接线路集成不';在用户键入内容之前,不要显示介绍性消息

Azure机器人程序框架-直接线路集成不';在用户键入内容之前,不要显示介绍性消息,azure,botframework,Azure,Botframework,我已经部署了一个Azure机器人,现在我正试图让它可用于测试 我已经按照说明将bot嵌入到一个单独的Azure web应用程序中(在html页面中),但在您键入内容之前,介绍性消息不会显示 因此,为了测试我的测试人员必须输入“go”(或类似)才能开始测试机器人 使用仿真器测试localhost是正常的 通过Azure门户进行测试也可以(但我的测试人员将无法访问Azure门户)。查看此演示如何在WebChat中实现该功能的内容查看此演示如何在WebChat中实现该功能的内容在您的Bot文件中,添加

我已经部署了一个Azure机器人,现在我正试图让它可用于测试

我已经按照说明将bot嵌入到一个单独的Azure web应用程序中(在html页面中),但在您键入内容之前,介绍性消息不会显示

因此,为了测试我的测试人员必须输入“go”(或类似)才能开始测试机器人

使用仿真器测试localhost是正常的


通过Azure门户进行测试也可以(但我的测试人员将无法访问Azure门户)。

查看此演示如何在WebChat中实现该功能的内容查看此演示如何在WebChat中实现该功能的内容在您的Bot文件中,添加以下代码:

protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
        {
            try
            {
                foreach (var member in membersAdded)
                {
                    if (member.Id != turnContext.Activity.Recipient.Id)
                    {
                        var Userid=turnContext.Activity.From.Name;
                        UserProfile userProfile = await _botStateService.UserProfileAccessors.GetAsync(turnContext, () => new UserProfile());
                        userProfile.name = Userid;
                        await _botStateService.UserProfileAccessors.SetAsync(turnContext, userProfile);
                        await turnContext.SendActivityAsync(MessageFactory.Text($" Hi, bot here "), cancellationToken);
                    }
                }
            }
受保护的覆盖MemberSaddedAsync上的异步任务(IList membersAdded、iTunesContext turnContext、CancellationToken CancellationToken)
{
尝试
{
foreach(membersAdded中的var成员)
{
if(member.Id!=turnContext.Activity.Recipient.Id)
{
var Userid=turnContext.Activity.From.Name;
UserProfile UserProfile=await _botStateService.UserProfileAccessors.GetAsync(turnContext,()=>newuserprofile());
userProfile.name=Userid;
wait_botStateService.UserProfileAccessors.SetAsync(turnContext,userProfile);
Wait turnContext.SendActivityAsync(MessageFactory.Text($“Hi,bot here”)、cancellationToken;
}
}
}

在Bot文件中,添加以下代码:

protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
        {
            try
            {
                foreach (var member in membersAdded)
                {
                    if (member.Id != turnContext.Activity.Recipient.Id)
                    {
                        var Userid=turnContext.Activity.From.Name;
                        UserProfile userProfile = await _botStateService.UserProfileAccessors.GetAsync(turnContext, () => new UserProfile());
                        userProfile.name = Userid;
                        await _botStateService.UserProfileAccessors.SetAsync(turnContext, userProfile);
                        await turnContext.SendActivityAsync(MessageFactory.Text($" Hi, bot here "), cancellationToken);
                    }
                }
            }
受保护的覆盖MemberSaddedAsync上的异步任务(IList membersAdded、iTunesContext turnContext、CancellationToken CancellationToken)
{
尝试
{
foreach(membersAdded中的var成员)
{
if(member.Id!=turnContext.Activity.Recipient.Id)
{
var Userid=turnContext.Activity.From.Name;
UserProfile UserProfile=await _botStateService.UserProfileAccessors.GetAsync(turnContext,()=>newuserprofile());
userProfile.name=Userid;
wait_botStateService.UserProfileAccessors.SetAsync(turnContext,userProfile);
Wait turnContext.SendActivityAsync(MessageFactory.Text($“Hi,bot here”)、cancellationToken;
}
}
}

您需要生成令牌,请在此处查看我的答案,说明如何使用邮递员生成令牌。您需要生成令牌,请在此处查看我的答案,说明如何使用邮递员使用WebChat或directline生成令牌。创建会话时会发送机器人的会话更新,首次发送时会发送用户的会话更新消息。在建立DirectLine连接时,您需要向bot发送反向通道欢迎事件,并从onEventAsync处理程序而不是onMembersAdded发送。使用WebChat或DirectLine,在创建对话时发送bot的ConversationUpdate,在用户首次发送对话时发送用户的ConversationUpdate一条消息。当建立DirectLine连接时,您需要向bot发送一个反向通道欢迎事件,并从onEventAsync处理程序而不是onMembersAdded发送一个。