简体   繁体   English

Webchat-Bot Framework(Nodejs)中的快速回复

[英]Quick Replies in Webchat- Bot Framework (Nodejs)

Messenger provides quick reply buttons for the bots as shown here 信使提供了机器人快速回复按钮,如图所示这里

However, I was interested to get the same on Microsoft Bot Framework Chat Interface. 但是,我有兴趣在Microsoft Bot Framework Chat Interface上获得相同的东西。 I figured out a C# method for doing the same which is as below: 我想出了一个C#方法来执行以下操作:

  var reply = activity.CreateReply("Hi, do you want to hear a joke?");
   reply.Type = ActivityTypes.Message;
reply.TextFormat = TextFormatTypes.Plain;

reply.SuggestedActions = new SuggestedActions()
{
    Actions = new List<CardAction>()
    {
        new CardAction(){ Title = "Yes", Type=ActionTypes.ImBack, Value="Yes" },
        new CardAction(){ Title = "No", Type=ActionTypes.ImBack, Value="No" },
        new CardAction(){ Title = "I don't know", Type=ActionTypes.ImBack, Value="IDontKnow" }
    }
};

How can I implement the same in Nodejs? 如何在Node.js中实现相同的功能?

Updated code: 更新的代码:

getMyID(session, args){var msg = new builder.Message(session)
            .text("Let me know the date and time you are comfortable with..")
            .suggestedActions(
                builder.SuggestedActions.create(
                    session,[
                        builder.CardAction.imBack(session, "green", "green"),
                        builder.CardAction.imBack(session, "blue", "blue"),
                        builder.CardAction.imBack(session, "red", "red")
                    ]
                )
            );
        builder.Prompts.choice(session, msg, ["green", "blue", "red"]), function(session, results) {
          console.log(results);
        session.send('I like ' +  results + ' too!');
    }}

How to take response from the choices and send message to user from inside this function (the current callback function is not being triggered)? 

Console.log is not working. Console.log无法正常工作。 I am seeing the below in command prompt. 我在命令提示符下看到以下内容。

.BotBuilder:prompt-choice - Prompt.returning([object Object])
.BotBuilder:prompt-choice - Session.endDialogWithResult()
/ - Session.endDialogWithResult()

There is a sample in the botbuilder repo That demonstrates this. botbuilder存储库中有一个示例对此进行了演示。 Below is a snippet: 以下是代码段:

var restify = require('restify');
var builder = require('../../core/');

// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
   console.log('%s listening to %s', server.name, server.url); 
});

// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});

var bot = new builder.UniversalBot(connector);
server.post('/api/messages', connector.listen());

bot.use(builder.Middleware.dialogVersion({ version: 1.0, resetCommand: /^reset/i }));

bot.dialog('/', [
    function (session) {

        var msg = new builder.Message(session)
            .text("Hi! What is your favorite color?")
            .suggestedActions(
                builder.SuggestedActions.create(
                    session,[
                        builder.CardAction.imBack(session, "green", "green"),
                        builder.CardAction.imBack(session, "blue", "blue"),
                        builder.CardAction.imBack(session, "red", "red")
                    ]
                )
            );
        builder.Prompts.choice(session, msg, ["green", "blue", "red"]);
    },
    function(session, results) {
        builder.LuisRecognizer.recognize(results.response.entity,"Model URL", function(error, intents, entities){
                //your code here
        })
    },

]);

暂无
暂无

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

相关问题 减少Bot Framework WebChat IFrame会话超时 - Reducing Bot Framework WebChat IFrame session timeout 带有 v4 网络聊天频道的 Bot Framework 问候语 - Bot Framework Greeting message with v4 Webchat Channel Microsoft Bot Framework WebChat (DirectLine) 导致 AJAX 页面回发 - Microsoft Bot Framework WebChat (DirectLine) causing Postback on AJAX Page Microsoft Bot Framework WebChat:禁用AdaptiveCards提交上一条消息的按钮 - Microsoft Bot Framework WebChat: Disable AdaptiveCards submit buttons of previous message 使用 Bot Framework v4 在 WebChat 中未呈现自适应卡片操作 - Adaptive cards actions not rendered in WebChat using Bot Framework v4 使用 ActivityPrompt 从网络聊天 BOT 框架 4 获取自定义事件 - Get custom event from webchat BOT Framework 4 using ActivityPrompt 如何在自定义网络聊天实现机器人框架中更改用户名/用户名 - How to change username/userid in custom webchat implementation bot framework 如何使用 C# 在机器人框架 SDKV4 中开发的网络聊天中显示每条消息的聊天日期和时间? - How to display chat date and time for every message in webchat developed in bot framework SDKV4 using C#? 有没有办法通过 bot 框架中的 CSS 或 C# 更改网络聊天中的字体大小? - Is there a way to change the font size in webchat either through CSS or C# in the bot framework? Bot framework Webchat Postback 按钮在我单击它们后会在聊天中显示文本 - Bot framework Webchat Postback buttons show the text on the chat after I click them
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM