Skip to content

xvare/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 passes the message responses, leveraging the Wit.ai context variables, from Wit.ai bot engine directly to the user.

This is a fork of q3blend's BotBuilder-Wit.ai repository. If you want support for the POST /converse endpoint, use q3blend's lib. If you want support for the GET /message endpoint, use this lib.

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 intent handlers for the actions defined in your Wit.ai application, decorate the handler methods like below:
[WitIntent("Intent Name")]

where the intent 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 "getMyForecast" action, which happens here:

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

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

            //adding temp to context
            Context["forecast"] =  temp;
        }

NuGet

https://www.nuget.org/packages/WoodenMoose.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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%