C# Microsoft Bot Framework-当未被要求时,Bot将返回特定单词

C# Microsoft Bot Framework-当未被要求时,Bot将返回特定单词,c#,bots,botframework,C#,Bots,Botframework,我一直在用一个很奇怪的虫子做实验。我发现在某些单词上,它只是返回消息。这是当前在Slack上运行的bot的代码: using System; using System.Linq; using System.Net; using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Web.Http; using Microsoft.Bot.Builder.

我一直在用一个很奇怪的虫子做实验。我发现在某些单词上,它只是返回消息。这是当前在Slack上运行的bot的代码:

using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Bot.Builder.Dialogs;
using System.Web.Http.Description;
using Microsoft.Bot.Connector;
using Newtonsoft.Json;

namespace SharpBot
{
    [BotAuthentication]
    public class MessagesController : ApiController
    {
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task<Message> Post([FromBody] Message message)
        {
                if (message.Type == "Message")
                {
                    // return our reply to the user
                    message.BotPerUserInConversationData = null;
                    return await Conversation.SendAsync(message, () => new EchoDialog());
                }
            return null;
        }
    }

    [Serializable]
    public class EchoDialog : IDialog<object>
    {
        public async Task StartAsync(IDialogContext context)
        {
            context.Wait(MessageReceivedAsync);
        }

        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<Message> argument)
        {
            var message = await argument;
            if (message.Text.ToLowerInvariant().Contains("echo request"))
            {
                await context.PostAsync("echo reply");
            }
            context.Wait(MessageReceivedAsync);
        }
    }
}
使用系统;
使用System.Linq;
Net系统;
使用System.Net.Http;
使用System.Text.RegularExpressions;
使用System.Threading.Tasks;
使用System.Web.Http;
使用Microsoft.Bot.Builder.Dialogs;
使用System.Web.Http.Description;
使用Microsoft.Bot.Connector;
使用Newtonsoft.Json;
名称空间SharpBot
{
[身份验证]
公共类消息控制器:ApiController
{
/// 
///帖子:api/Messages
///接收来自用户的消息并回复
/// 
公共异步任务发布([FromBody]消息)
{
如果(message.Type==“message”)
{
//将我们的回复返回给用户
message.botperUserConversationData=null;
return wait Conversation.sendaync(message,()=>newechodialog());
}
返回null;
}
}
[可序列化]
公共类EchoDialog:IDialog
{
公共异步任务StartAsync(IDialogContext上下文)
{
Wait(MessageReceivedAsync);
}
公共异步任务消息ReceivedAsync(IDialogContext上下文,IAwaitable参数)
{
var message=等待参数;
if(message.Text.ToLowerInvariant()包含(“回显请求”))
{
等待上下文。PostAsync(“回音回复”);
}
Wait(MessageReceivedAsync);
}
}
}
正如你所看到的,这是非常直截了当的。当用户写入
回显请求
时,它返回
回显回复
。这就行了。如果用户不写,它应该忽略它,对吗?我对它说的99%的话它都忽略了。但是如果我写下单词“rus”,它只会回复“rus”

我不可能知道它为什么会这样。我看不出代码有任何错误,所以它可以是一个机器人程序框架中的一个错误吗


首先,我认为这个问题与Slack有关,但是在我的bot上实现了FB-Messenger之后,我注意到它也发生在那里。奇怪的是,我的电脑上的Bot仿真器没有出现这种情况,这让我觉得它可能与代码无关。

我已经通过关闭Bot框架的翻译服务解决了这个问题。我仍然不知道为什么它会返回这些单词。我怀疑这是他们这边的一只虫子