首页 > 解决方案 > 如何将密码活动表单bot传递到microsoft bot框架中的前端

问题描述

我正在尝试实现此链接中显示的密码功能。 https://github.com/microsoft/BotFramework-WebChat/tree/master/samples/05.custom-components/f.password-input

但是如何将密码活动从机器人传递到前端。我正在使用 c# 模板来开发机器人。

根据我的理解,我们需要将密码活动从机器人传递到前端,以执行链接中提到的密码内容。

一个示例将有助于了解如何将这种类型的客户活动传递给机器人。

谢谢,

标签: botframeworkazure-bot-service

解决方案


我自己将这个样本用于我的一个机器人。机器人逻辑内置在节点中,但我想翻译成 c# 应该不难

        const askPwd =
    {
        name: 'passwordInput',
        type: 'event'
    };
    await stepContext.context.sendActivity(askPwd);
    return await stepContext.prompt(PASSWORD_PROMPT, '');

在 c# 中,这可能会翻译成这样的东西(我不知道 c#):

Activity activity = new Activity
        {
            Type = ActivityTypes.Event,
            Name = "passwordInput"
        };
        await stepContext.Context.SendActivityAsync(activity, cancellationToken);});

推荐阅读