Developing a ‘conversational’ Facebook Chatbot

Following the successful work done with Microsoft developing the weather and climate bot the Informatics Lab have been busy creating a more user-friendly, public-facing bot, due appear on Facebook Messenger as a prototype in the very near future.

Using virtually the same tool set (Microsoft Bot Framework and LUIS) significant time and effort has been spent working on features that will hopefully make our bot respond similar to how a person might, we hope this will provide a more conventional messenger experience than some existing similar bots currently provide.

Here’s some of the stuff we’ve been working on:

Interchangeable persona with multiple responses per intent:
Most bots already provide a means of replying to the same question in multiple ways. Our bot definitely has this too, however what’s new is all our responses are read from a single JSON file. This gives us the flexibility to completely alter all the bot’s responses (style and tone of how it responds) with a single update.

Expiry of contextual, conversational information:
Say a user asks for a forecast in a given location. The bot will remember we are talking about that location for a period of time, allowing the user to ask follow up questions more intuitively; “Will it be cold in Exeter today?”, “Will I need a coat?”

Repeat intents:
This allows for users to ask the same thing multiple times, potentially just adjusting the question slightly; “Will I need a coat today?”, “How about tomorrow?”

Variable certainty responses:
Say a user asks “Will I need a coat tomorrow in Brighton?” our bot knows a user might need a coat if the temperature is low, but also if it’s likely to rain. The bot can use lists of weather variables to score questions against some given rules. Scores are then combined in various ways to calculate a score for how sure we are that a user should take action. The variation of certainty can be conveyed to the user via matching appropriately scored responses.

Multimedia responses:
The bot can respond with various images (including animated gifs) and videos along with varying textual information. We have also implemented the Facebook Messenger UI buttons to aid some basic usage.

String templating with dot.js:
We have enabled dynamic content, by inserting string templates then applying a data model to it. This allows us to inject data and evaluate conditional statements at runtime further modifying our responses.

Deployment, logging and analytics:
Our app is a single node.js server running on an Amazon EC2 instance, inside a docker container. All of this is managed using Terraform. Conversations are tracked on several analytics platforms, including Google Analytics. This enables us to see exactly what the most frequent questions are. The data collected here can inform the development of new features, prioritising those that users really want. We are using a neat library called sentry to track any errors, this is set up to email us if something goes wrong. All logs are piped into Amazon’s Cloudwatch.

Other features we would still ideally like to develop or explore include; push notification alerts. Varied personas, each targeting a specific user demographic, and expanding on some of the basic functionality we have already implemented.

As with all Informatics Lab prototypes, this project is simply a ‘proof of concept’ at the moment. We hope that via a combination of the analytics data generated plus data collected through user surveys, we can gather enough evidence and requirements to inform a proposal for an official Met Office Chatbot.

Try out our prototype by clicking the button below…