Sharing Top Content from the Angular-sphere.

Building bots with Redux

  • In this post, to explore how flexible the Azure Bot Service can be, we’ll be venturing into relatively uncharted territory – we are going to build a bot and attempt to use as little of the bot builder SDK as possible, by leveraging another library to handle our bot’s dialog…
  • Redux developers should feel right at home, and our goal today is to demonstrate that you can author bot conversational flows on the Azure Bot Service using many different technologies/libraries, developers are not restricted to what is provided by the bot builder SDK.
  • The next parts of the article are more conceptual, and we’ll break everything into three main steps: – – Redux defines three concepts which we’ll introduce briefly, and explain how each relates to our bot: – – State in the store is updated by Actions, which are plain JavaScript objects…
  • Back to our sample bot, in app.js, we can set up the root dialog to take incoming messages from a user, and dispatch the message as an action to the store.
  • When a user sends a message to the bot, LUIS will return an intent, and that intent is dispatched as an action to redux store.

A key part of what makes the Azure Bot Service so great is it’s flexibility, which we’ve been emphasizing from the very beginning. When we’ve talked about flexibility in the past, we’ve typically referred to the Azure Bot Service’s ability to seamlessly connect your bots to multiple channels at once, and the option to easily add cognitive services such as LUIS or QnAMaker to create rich conversational experiences. In this post, to explore how flexible the Azure Bot Service can be, we’ll be venturing into relatively uncharted territory – we are going to build a bot and attempt to use as little of the bot builder SDK as possible, by leveraging another library to handle our bot’s dialog and user interaction.

Redux is a popular open source library which acts as a state container for JavaScript applications. It is currently perhaps most commonly used along side Facebook’s React.js library for building user interfaces. In a way, much of what a chat bot does is performing some task to process information – contextual conversation data, and user data. For this reason we thought that redux would make a great tool to experiment with, and we will showcase this by re-creating an existing bot.

This sample from the BotBuilder-Samples repo prompts the user for their name, and simply performs a bing search within a specified city.

Let’s get to it!

First we need to provide some (hopefully familiar) boilerplate code. For  new bot developers, this is the only…

Building bots with Redux