【问题标题】:Syn Bot - Oscova WidgetChannel cannot display HintSyn Bot - Oscova WidgetChannel 无法显示提示
【发布时间】:2021-12-29 01:18:54
【问题描述】:

将 Syn.Bot 从 2.9 版本更新到 4.6 后,Bot 只能显示 Text 而不能显示 Hint。 尝试添加 Dialog 或导入 Oryzer 工作场所具有相同的结果...我是 Syn Bot 的初学者,有人可以帮帮我吗?谢谢。

using System;
using System.Web;
using System.Web.UI;
using Syn.Bot.Channels.Widget;
using Syn.Bot.Oscova;
using Syn.Bot.Oscova.Attributes;

namespace BotWebsite
{
    public partial class BotService : Page
    {
        private static WidgetChannel WidgetChannel { get; }
        private static OscovaBot bot { get; }
        static BotService()
        {
            bot = new OscovaBot();
            //bot.ImportWorkspace("");
            WidgetChannel = new WidgetChannel(bot);
            bot.Dialogs.Add(new AppDialog());
            bot.Dialogs.Add(new ProductDialog());

            bot.Trainer.StartTraining();

            var websiteUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);
            WidgetChannel.ServiceUrl = websiteUrl + "/BotService.aspx";
            WidgetChannel.ResourceUrl = websiteUrl + "/BotResources";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            WidgetChannel.Process(Request, Response);
        }
    }

    public class ProductDialog: Dialog
    {
        [Expression("test")]
        public void test(Result result)
        {
            var response = new Response();
            response.Text = "I was expecting a yes or no answer.";
            response.Hint = "Yes|No";
            result.SendResponse(response);
        }
    }

}

【问题讨论】:

    标签: c# asp.net asp.net-mvc bots syn


    【解决方案1】:

    虽然在这里聚会有点晚了。这可能对将来的某人有所帮助。您可以通过将 test 方法的主体替换为以下内容来实现您的要求。

    var response = new Response();
    
    response.Messages.Add(
        new QuickReplyMessage
        {
            Title = "I was expecting a yes or no answer.",
            Replies = new List<string>
            {
                "Yes",
                "No",
            }
        });
    
    result.SendResponse(response);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-03
      • 2012-03-12
      • 2022-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-08
      相关资源
      最近更新 更多