Skip to content

Extending the BotBuilder SDK to support WIt.ai Dialogs. A Wit.ai Dialog should follow the path of conversation on the Wit.ai conversation until it waits for more input for the user, or the conversation is done.

License

q3blend/BotBuilder-Wit.ai

Repository files navigation

Wit.ai Bot Framework Integration

Overview

This is an integration between Wit.ai and Microsoft Bot Framework. Wit.ai allows users to create full fledged dialogs that can contain placeholders for actions, with expected inputs and outputs. This integration will facilitate the implementation of the actions, and automatically paseses the message responses, leveraging the Wit.ai context variables, from Wit.ai bot engine directly to the user.

Getting Started

  • Go to Wit.ai to an existing application, or create a new one.
  • Go to Settings tab, and copy the Server Access Token.
  • Extend WitDialog class and decorate it like below:
[WitModel("Access Token")]
  • To define action handlers for the actions defined in your Wit.ai application, decorate the handler methods like below:
[WitAction("Action Name")]

where the action name is how you defined it in your application.

Use Case and Features

This is useful when you want to create a bot using wit.ai for language understanding and conversation flow. Microsoft Bot Framework is useful for making it easy to publish on several channels and having a good code structure. It's a great place to implement your action and update the wit context variables as well.

Sample

Weather App

The WitWeather sample uses Wit.ai weather application.

alt tag

We can see here that "getMyForecast" action needs to be executed. It is expected that location and forecast context variables will be added/updated in "getMyForecast" action like below:

[Serializable]
[WitModel("Access Token")]
public class WeatherDialog : WitDialog

First, we added the Server Access Token. Now, we need to implement the "getMyForcast" action, which happens here:

        [WitAction("getMyForecast")]
        public async Task GetForecast(IDialogContext context, WitResult result)
        {
            //adding location to context
            this.WitContext["location"] =  result.Entities["location"][0].Value;

            //yahoo weather API
            var temp = await GetWeather(this.WitContext["location"]);

            //adding temp to context
            this.WitContext["forecast"] =  temp;
        }

NuGet

https://www.nuget.org/packages/Microsoft.Bot.Builder.Witai/

More Information

Read these resources for more information about the Microsoft Bot Framework, Bot Builder SDK and Wit.ai Services:

About

Extending the BotBuilder SDK to support WIt.ai Dialogs. A Wit.ai Dialog should follow the path of conversation on the Wit.ai conversation until it waits for more input for the user, or the conversation is done.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages