0

将 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);
        }
    }

}
4

1 回答 1

0

虽然在这里聚会有点晚了。这可能对将来的某人有所帮助。您可以通过将方法的主体替换为以下内容来实现您的要求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);
于 2021-12-22T01:17:14.547 回答