如果我建立一个机器人与微软博特框架,做我需要部署我的机器人,以便注册我的机器人到Azure 这里以配置机器人的渠道?或者我可以简单地将我的机器人部署到正常(例如)IIS服务器?
我无法找到关于这个toppic的任何信息,我不想使用Azure.
我无法弄清楚如何在MS Bot Framework中做一个非常简单的事情:允许用户打破任何对话,离开当前对话框并通过键入"quit","exit"或"返回主菜单"重来".
这是我的主要对话设置方式:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
try
{
if (activity.Type == ActivityTypes.Message)
{
UserActivityLogger.LogUserBehaviour(activity);
if (activity.Text.ToLower() == "start over")
{
//Do something here, but I don't have the IDialogContext here!
}
BotUtils.SendTyping(activity); //send "typing" indicator upon each message received
await Conversation.SendAsync(activity, () => new RootDialog());
}
else
{
HandleSystemMessage(activity);
}
}
Run Code Online (Sandbox Code Playgroud)
我知道如何终止一个对话框context.Done<DialogType>(this);,但在这个方法中,我没有访问IDialogContext对象,所以我无法调用.Done().
当用户键入某个消息时,除了在所有对话框的每个步骤中添加一个检查之外,还有其他方法可以终止整个对话框堆栈吗?
发表赏金:
我需要一种方法来终止所有IDialogs而不使用我在这里发布的令人发指的黑客攻击(删除我需要的所有用户数据,例如用户设置和首选项).
基本上,当用户键入"退出"或"退出"时,我需要退出IDialog当前正在进行的任何操作并返回到新状态,就好像用户刚刚发起了对话一样.
我需要能够从MessageController.cs,我仍无法访问的地方执行此操作IDialogContext.我似乎唯一有用的数据是Activity对象.如果有人指出其他方法,我会很高兴.
另一种方法是找到一些其他方法来检查机器人的其他位置的"退出"和"退出"关键字,而不是在Post方法中.
但它不应该是在每一步都完成的检查IDialog,因为这是太多的代码,甚至不可能(当使用时PromptDialog …
我有一个运行在Azure + Bot Framework + LUIS(通过LuisDialog)的机器人.
如果用户碰巧快速连续发送两条消息(在机器人有机会回答之前),他们会在Facebook Messenger或web embed上看到此错误消息:
对不起,我的机器人代码有问题.
通过bot通道模拟器进行调试时,我发现错误是这样的:
"text":"错误:响应状态代码未指示成功:429(请求太多).在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)处于System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) Microsoft.Bot.Builder.Luis.LuisService.d__4.MoveNext()
堆栈跟踪的结尾显示错误源自MessageController.cs中的此行:
await Conversation.SendAsync(activity, () => new LuisRootDialogEnglish());
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为我使用的是付费版本的LUIS,每秒最多可以拨打10个电话.
在任何情况下,我都尝试将MessageController.cs中的整个代码包装到一个try/catch块中,并且无论异常如何都返回此值:
return Request.CreateResponse(HttpStatusCode.OK);
Run Code Online (Sandbox Code Playgroud)
仍然,用户看到错误消息"抱歉,我的机器人代码有问题",这基本上意味着存在未处理的异常.
如何防止向用户显示此消息或捕获异常?
我目前正在与微软的Bot Framework进行聊天机器人.在我的流程中,我有一个最终对话框,让用户知道他们正在参加比赛.对于未知输入,还有一种错误处理方法.这里有两种方法:
[Serializable]
public class ConcertCityDialog : AbstractBasicDialog<DialogResult>
{
private static FacebookService FacebookService => new FacebookService(new FacebookClient());
[LuisIntent("ConcertCity")]
public async Task ConcertCityIntent(IDialogContext context, LuisResult result)
{
var fbAccount = await FacebookService.GetAccountAsync(context.Activity.From.Id);
var selectedCityName = result.Entities.FirstOrDefault()?.Entity;
concert_city selectedCity;
using (var concertCityService = new ConcertCityService())
{
selectedCity = concertCityService.FindConcertCity(selectedCityName);
}
if (selectedCity == null)
{
await NoneIntent(context, result);
return;
}
user_interaction latestInteraction;
using (var userService = new MessengerUserService())
{
var user = userService.FindByFacebookIdIncludeInteractions(context.Activity.From.Id);
latestInteraction = user.user_interaction.MaxBy(e => e.created_at);
}
latestInteraction.preferred_city_id = selectedCity.id; …Run Code Online (Sandbox Code Playgroud) 我首先通过OAuthCallback方法中的短信通道向用户发送主动消息
var connector = new ConnectorClient();
Message message = new Message();
message.From = new ChannelAccount { Id = Constants.botId, Address = "+12312311", ChannelId = "sms", IsBot = true };
message.To = new ChannelAccount { Id = newUserId, Address = "+18768763", ChannelId = "sms", IsBot = false };
message.Text = $"How are you doing? ";
message.Language = "en";
connector.Messages.SendMessage(message);
IBotData myDataBag = new JObjectBotData(message);
myDataBag.UserData.SetValue("Username", "Bob");
myDataBag.PerUserInConversationData.SetValue("Newuser", "yes");
Run Code Online (Sandbox Code Playgroud)
然后在我的主Dialog.cs中尝试访问它
public static readonly IDialog<string> dialog = Chain
.PostToChain()
.Switch(new Case<Message, IDialog<string>>((msg) => …Run Code Online (Sandbox Code Playgroud) 我正在使用Microsoft bot框架创建机器人,机器人将接收餐馆的订单,我想知道如何处理多个对话框,例如客户发出第一个订单,然后我希望机器人问你做什么想要别的吗?然后客户说是/否,因为保持第一个状态再次重复相同的dailog,我现在在文档中看到的只有一个对话和一个对话框.
非常感谢
我从黑客新闻中分享的一个链接介绍了BOTBUILDER.
我已经创建了我的第一个bot应用程序,但它在Bot框架模拟器中运行时出错.它显示我发送的消息的状态,如"无法发送".请建议我可能是什么原因.

我正在运行部署到azure webapp的机器人.机器人在本地调试中运行良好,并且在Azure门户中的Web测试客户端中运行良好.
我可以从bot框架模拟器连接到bot,我可以从浏览器访问其默认的html首页,但是当我向REST api发送消息时,它会返回以下错误.
我对状态代码"PaymentRequired"感到困惑.根据堆栈跟踪,我无法弄清楚它来自何处.我的机器人处于S1标准定价层.当我访问App Service Plan刀片时,它说我在Default0(Free:0 Small)计划中.当我访问Change App Service Plan时,它说"找不到应用服务计划".对于它的价值,我不认为这是一个LUIS问题,因为当我从其他客户端连接时,LUIS工作正常.
Buffer="{
"message": "An error has occurred.",
"exceptionMessage": "Operation returned an invalid status code 'PaymentRequired'",
"exceptionType": "Microsoft.Bot.Connector.ErrorResponseException",
"stackTrace":
" at Microsoft.Bot.Connector.Conversations.<ReplyToActivityWithHttpMessagesAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Connector.ConversationsExtensions.<ReplyToActivityAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Bot.Builder.Dialogs.Internals.AlwaysSendDirect_BotToUser.<Microsoft-Bot-Builder-Dialogs-Internals-IBotToUser-PostAsync>d__4.MoveNext() in D:\a\1\s\CSharp\Library\Microsoft.Bot.Builder\ConnectorEx\BotToUser.cs:line 124
--- End of stack …Run Code Online (Sandbox Code Playgroud) 我有一个基于BotFramework 3.5的机器人,并作为WebApp托管在Azure上.我没有遇到机器人需要响应用户输入的情况的实施问题.但是,有必要教他按一些时间表开始对话.为了达到目标,我创建了一个WebJob,它基本上是一个简单的控制台应用程序.以下是用于启动从bot到用户的消息的代码:
var botAccount = new ChannelAccount(id: from);
var userAccount = new ChannelAccount(id: to);
var conversation = new ConversationAccount(false, conversationId);
var connector = new ConnectorClient(serviceUrl);
IMessageActivity message = Activity.CreateMessageActivity();
message.From = botAccount;
message.Recipient = userAccount;
message.Conversation = conversation;
message.Text = text;
message.Locale = locale;
await connector.Conversations.SendToConversationAsync((Activity)message);
Run Code Online (Sandbox Code Playgroud)
from, to, serviceUrl, conversationId - 取自之前的对话,所以我希望它们有效.但是SendToConversationAsync 抛出异常:
System.UnauthorizedAccessException: Authorization for Microsoft App ID 3a26a4d4-f75a-4feb-b3e0-37a7fa24e5fc failed with status code Unauthorized and reason phrase 'Unauthorized' ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 …Run Code Online (Sandbox Code Playgroud)