Arn Vanhoutte
Arn Vanhoutte

Reputation: 1927

Microsoft Bot Framework - Bot returns specific words when not asked to

I've been experimenting a bit with a very weird bug. I found out that on some words, it just returns the message back. So this is the code of a bot that's currently running on Slack:

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

As you see, it is very straight forward. When a user writes echo request, it returns echo reply. And that works. If a user doesn't write that, it should just ignore it, right? And it does ignore it for 99% of the words I say to it. But if I write the word rus, it just replies `rus.

I cannot possibly find out why it does that. I can't see anything wrong with the code, so can it be a but in the Bot Framework?

First I thought the problem was related to Slack, but after implementing FB Messenger to my bot I noticed it happens there too. Weirdly enough, it does not happen on the Bot Emulator on my PC, which makes me think it might not be code related.

Upvotes: 3

Views: 209

Answers (1)

Arn Vanhoutte
Arn Vanhoutte

Reputation: 1927

I have been able to fix the problem by turning off the translation service of the Bot Framework. I still have no idea why it returns those words though. I suspect it's a bug on their side

Upvotes: 2

Related Questions