Receiving files sent to your botframework chatbot

We’ve already looked at how a botframework bot receives messages, and even how to save those messages.

In this article I’ll show you how to handle files that are sent to your botframework chatbot.

When a user interacts with your bot, unless they’re responding to a prompt, they will cause the Message controller’s Post method to fire with an activity.

This will send a message through to your underlying IDialog or LuisDialog implementation.

MessageReceived

The method that receives the message will have the signature (though the parameter names and method name could be different):

Continue reading

Transcribing messages in BotFramework

Now that you’ve deployed your well structured, exception handling, language understanding chatbot, how do you know just what people are saying to it?

Sure, you could copy and paste some logging code all over the place, but there must be a cleaner way.

In this article I’ll show you a few simple tricks to be able to save each message going to and from your botframework chatbot.

IDialog

Let’s start off by saving messages going to any dialog that implements IDialog<T>.

In order to implement IDialog<T> you only need to implement the StartAsync method; however, this isn’t much use on its own, so let’s get the dialog into a conversation loop by adding in a MessageReceivedAsync method and calling that from StartAsync and from itself:

Continue reading

LDNBotFramework Meetup #2 Retrospective: From Zero to Echo via BotFramework

I had an awesome time presenting my session at the second LDNBotframework meetup!

This time I ordered the correct amount of pizza, and let people loose on it at the right time; so no fridge full of pizza for breakfast the next day!

From Zero to Echo via BotFramework

LDNBotFramework #2 - From Zero to Echo via BotFramework

Tight deadline

Having scheduled this session weeks ago, unfortunately my preferred presenters were not able to make it; as such I had just over a week to decide what to do about the already scheduled meetup: should I cancel it and lose momentum, or should I do a session myself?

Continue reading

BotFramework: Avoiding have to make everything [Serializable]

In the last article I touched on how IoC is used within botframework using Autofac.

If you’re comfortable with IoC, you probably started to enhance your dialogs using constructor injection, so that you can put your conversation logic outside of your entry point and just start coding without needing an implementation to exist yet, e.g.,

[Serializable]
public class ResolvingDialog : IDialog<object>
{
    private readonly IMessageRepository _messageRepository;

    public ResolvingDialog(IMessageRepository messageRepository)
    {
        _messageRepository = messageRepository;
    }

    public async Task StartAsync(IDialogContext context)
    {
        await context.PostAsync($"Hi!");
        context.Wait(MessageReceivedAsync);
    }

    public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
    {
        var message = await argument;
        await _messageRepository.SaveMessage(message);

        await context.PostAsync($"working now");
        context.Wait(MessageReceivedAsync);
    }
}

Continue reading

BotFramework Exception Wrapping and Custom Error Message

During your time building and debugging your botframework chatbot, you’ve probably already come across the annoyance of seeing a huge error message with a ridiculous stack trace that doesn’t seem to relate to your error, or even just a plain old HTTP 500 and big red exclamation mark..

emulator red exclamation mark

Perhaps you’ve deployed to a production environment and are stuck with the stock error message:

Sorry, my bot code is having an issue

In this article I’ll show you how to 1) display useful exception information, and 2) override the default error message sent to the user

Continue reading

Inaugural LDNBotFramework Meetup Retrospective

We recently wrapped up the first #LDNBotFramework meetup! There were a lot of lessons learned for me, as a first time meetup organiser, and overall I think it was a success.

The venue was great; the big video wall in JustEat’s Fleet Place House office combined with a mic and speaker system that “just works”, a stocked beer fridge and far too much pizza, all made for a perfect tech meetup setup.

LDNBotFramework Team #1!

Erdeniz Hassan, Simon Michael, Robin Osborne, and David Low

Thanks to @beanbaglabs for this group pic!

Sessions

We were very lucky to have representation from Microsoft to kick things off, then some great insights from SkyScanner’s case study, finishing off with a lightning talk on user expectations from JustEat.

Continue reading

Implementing LUIS Routing within BotFramework

In the previous LUIS article, I introduced how to set up and train (and publish) a LUIS language interpreting web service, getting an “intent” and extracting “entities” from a given “utterance”

In this article I’ll use LUIS to enhance your botframework chatbot

If you haven’t done so already, create your bot using botframework, and set up a LUIS application.

Now that we’ve laid the foundations, let’s build a house. A ..um. chatbot house.. yeah.

Continue reading

The Chatbot Revolution and The London BotFramework Meetup Group

If you’re one of the few people who have managed to avoid the onslaught of Chat Bot related articles over the past year, then let me start by way of an introduction; a chatbot is, in it’s most basic form, a computer program that can mimic basic human conversations.

This isn’t particularly new or exciting; this sort of chat bot has been around since the 70s. What is new and exciting is the recent development in systems and frameworks which make creating your own chat bot easy enough that you can focus on the quality of the interaction with the end user instead of wallowing in the technical considerations.

There is a website with a form to fill in that will give you a chat bot at the end of it, all the way through to an enterprise company’s framework for building your bespoke conversational interface from scratch.

Continue reading

LUIS Natural Language Service for BotFramework

Creating a hosted bot using Microsoft’s botframework couldn’t be easier; hopefully you’ve had a chance to create one already, and if not there’s a great introduction to creating your first bot right here.

In the previous article we saw how to create a QnA (aka FAQ/Knowledge Base) service using a little known QnA Maker service of the botframework.

In this post we’ll start to create a more intelligent bot; one which can appear to understand the intent of the incoming message and extract specific key variables from it.

Understanding the intent of a piece of text is a really tricky problem to solve; totally out of scope for this article, and for most bot projects! Luckily, the botframework has a friend called LUIS – the Language Understanding Intelligence Service.

Continue reading

Botframework Data URI images

A quick botframework tip – you can include images in your message attachments by Data URI, not just by URL!

For example, constructing a message like this:

var reply = message.CreateReply("Here's a **datauri image attachment**");
reply.Attachments = new List<Attachment> {
    new Attachment()
    {
        ContentUrl = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCAAQABADAREAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAACAUH/8QAJhAAAQMDAwQCAwAAAAAAAAAAAQIDBQQGEQcIEgATISIUMRUjUf/EABYBAQEBAAAAAAAAAAAAAAAAAAMBBP/EAB8RAAICAQQDAAAAAAAAAAAAAAECAAMRBBITIiFB8P/aAAwDAQACEQMRAD8AubjdVbtj5cQFi3tX2lS/ka16Rko9pZqHHfklplgKAylJPNR/vEZPWyvTpUN7jMyK3M21fE03ZLuQ1Gmbyc0j1Dudq7o8RztXFzXEGtacZeQhxipKT7D9qcKUOQ+skfRWKrdqxj71HI4erHME97633Fc+pF10c64pIg7ll6CldoEcHEoTVL7fMZ9se2CPOekdkCiSjIYmLvYvMRdLQPXDG3FGSEzK1iKB4rYCnaan7oVwcCQCHVqGTkkeEefGOgbTtjccyW6sM4QAT//Z",
        ContentType = "image/jpg",
        Name = "datauri"
    }
};

Gives a response that looks like this:

Continue reading