重试提示自定义 [英] Retry prompt customization

查看:130
本文介绍了重试提示自定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MS bot生成器node.js SDK.在最近的更新之一之前,重试提示时,它正在向用户发送与重试提示相同的消息文本.

I am using MS bot builder node.js SDK. Before one of the recent updates, when the prompt is retried, it was sending the same message text to the user as the retry prompt.

但是,现在它正在系统中发送默认短信,即我听不懂,请重试".但是,我希望重试提示始终与原始消息相同,并且如果可能的话,希望将其全局应用,这意味着我不想为发送给用户的每个提示自定义重试提示.

However, now it is sending the default text message in the system, which is "I didn't understand.Please try again". However, I want retry prompts always be the same as the original message and if possible want to apply this globally, meaning I don't want to customize retry prompt for every prompt I am sending to the user.

我一直在环顾四周,但找不到方法.

I had been looking around, but couldn't find a way yet.

谢谢!

推荐答案

您可以修改提示以将提示自动设置为重试提示. Prompts界面显示了如何将args传入基类Prompt,因此我们可以通过访问Prompts中的方法来修改此提示行为.

You can modify the prompts to automatically set the prompt as the retry prompt. The Prompts interface shows how the args are passed in to the base Prompt classes, so we can modify this prompt behavior by accessing the method in Prompts.

以下是使用 Prompts.confirm

Here's an example of how to do it with Prompts.confirm

const promptPrefix = 'BotBuilder:prompt-';

bot.dialog('/', [
  (session) => {
    builder.Prompts.confirm(session, 'Say yes or no');
  },

  (session, args) => {
    session.endConversation('You said: ' + session.message.text);
  }
]);

builder.Prompts.confirm = (session, prompt, options) => {
  var args = options || {};
  args.prompt = prompt || args.prompt;

  // If options.retryPrompt was passed in use this, otherwise use prompt
  args.retryPrompt = args.retryPrompt || args.prompt;
  session.beginDialog(promptPrefix + 'confirm', args);
};

修改后的Prompts.confirm动作:

The modified Prompts.confirm in action:

这篇关于重试提示自定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆