Wit.ai is a natural language processing (NLP) tool that helps developers get structured data from chat or voice. Wit.ai makes it easy to build NLP into your chat bot, that learns from every interaction. Gupshup's Bot Builder tool has a Wit.ai integration that will simplify the bot building process for any developer.
Before you get started with your Hello World program on Gupshup using wit.ai, here's a small introduction that will cover the essentials.
Intents and entities are the basis on which wit.ai (or any other NLP tool) can parse data from your user. Intents represent a mapping between what a user says and what action should be taken by your software.[1]
Example: If a user types out 'What's the weather in San Francisco?', the intent here is weather.
Entities represent concepts that are often specific to a domain as a way of mapping natural language phrases to canonical phrases that capture their meaning. Entities are a tool for extracting parameter values from natural language inputs.[2]
Example: In a weather bot, a user can query the bot and ask for the weather in a particular city. A typical query can look like: 'What's the weather in London?' and the bot will return with a weather report. Other queries can be for the weather in Bangalore, Paris, Stockholm or any other location. Thus the domain that is common to all these queries is location, which is the entity here.
An example conversation your bot has with a user is a story. A story represents the types of conversations that users will have with your bots and usually contains multiple intents and entities. Wit.ai gives bot developers options for how the bot can respond to the user. Stories rely on entities and context to predict the next action, they don't consider the raw natural language sentences. This is done by the Understanding feature.
NLP involves taking natural language (text or voice) and turning it into structured data that is machine-readable. This machine-readable data can be used by Stories to respond to the user.
What Understanding does is train the bot to understand natural language sentences. A bot developer can do this by adding examples of sentences that the bot might encounter, and indicating the intents and entities in these sentences.
Example: Consider our aforementioned weather bot. There are numerous ways to enquire about the weather in a city. 'Is it snowing in New York' or 'Do I need an umbrella in Tokyo?' are alternate ways of asking for a weather forecast. The Understand feature needs such inputs along with the entities and intents marked out. A greater number of sentences improves the bot's understanding.
The Inbox feature aggregates the messages received by your chat bot, whose entities couldn't be parsed by wit.ai. You can choose to add this new word/phrase to an entity and validate it. The Inbox is a way to ensure that your bot can parse any natural language sentences in its domain.
merge() and say() are helper functions provided by Gupshup in the wit.ai tab, as part of the template code. The merge() function is used to obtain the entity set that the developer defines in Wit. The say() function can be used to send a bot response to the user. The following guides will illustrate the usage of these functions with examples.
Our next guide will illustrate a Hello World-esque demo using wit.ai and Gupshup.
[1][2] api.ai key concepts