The api.ai .NET Library makes it easy to integrate the API.AI natural language processing API into your .NET application. API.AI allows using voice commands and integration with dialog scenarios defined for a particular agent in API.AI.
Library provides simple programming interface for making text and voice requests to the API.AI service.
You can be downloaded as sources from the Releases page.
Assumed you already have API.AI account and have at least one agent configured. If no, please see documentation on the API.AI website.
First, add following usages to your module:
using ApiAiSDK;
using ApiAiSDK.Model;
Then add ApiAi
field to your class:
private ApiAi apiAi;
Now you need to initialize ApiAi
object with appropriate access keys and language.
var config = new AIConfiguration("YOUR_CLIENT_ACCESS_TOKEN", SupportedLanguage.English);
apiAi = new ApiAi(config);
Done! Now you can easily do requests to the API.AI service
-
using
TextRequest
method for simple text requestsvar response = apiAi.TextRequest("hello");
-
using
VoiceRequest
method for voice binary data in PCM (16000Hz, Mono, Signed 16 bit) formatvar response = apiAi.VoiceRequest(voiceStream);
Also see unit tests for more examples.
- JSON parsing implemented using Json.NET.