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.
- 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.
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.
The WitWeather sample uses Wit.ai weather application.
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;
}
https://www.nuget.org/packages/Microsoft.Bot.Builder.Witai/
Read these resources for more information about the Microsoft Bot Framework, Bot Builder SDK and Wit.ai Services: