Releases: dialogflow/dialogflow-dotnet-client
Added messages field to fulfillment
Improvements for contexts
From this release you can put some additional parameters to your input contexts and set lifespan for the context. Take a look:
var aiContext = new AIContext
{
Name = "weather",
Parameters = new Dictionary<string, string>
{
{ "location", "London"}
},
Lifespan = 2
};
In the sample we create context with one parameter and set it Lifespan
to 2.
Lifespan
value determines for how many requests context will affect the result.
Windows 10 and Windows Phone 8
This release adds Windows 10 Universal Apps support. Also, Windows Phone 8 version moved from separate Nuget library to common Nuget library.
Fixed bug with parameters processing
This release contains breaking change in model Result
class.
public Dictionary<string, string> Parameters { get; set; }
replaced with
public Dictionary<string, object> Parameters { get; set; }
So, Parameters
dictionary now can contain structured Json objects.
You can get it with
public JObject GetJsonParameter(string name, JObject defaultValue = null)
See this code for sample
User entities and contexts
User Entities and Contexts can be added to the request with such code:
var myDwarfs = new Entity("dwarfs");
myDwarfs.AddEntry(new EntityEntry("Ori", new [] {"ori", "Nori"}));
myDwarfs.AddEntry(new EntityEntry("bifur", new [] {"Bofur","Bombur"}));
var extraEntities = new List<Entity> { myDwarfs };
var extraContexts = new List<AIContext> { new AIContext { Name = "someContext" } };
apiAi.TextRequest("hello", requestExtras);
WP8 and new protocol
Now you can use base API.AI Library in your Windows Phone 8 project. The API is quite similar to the generic .NET SDK, but uses async methods
async Task<AIResponse> TextRequestAsync(string text)
async Task<AIResponse> TextRequestAsync(AIRequest request)
async Task<AIResponse> VoiceRequestAsync(Stream voiceStream)
Also, please note the protocol change.
Now Fulfillment field from API.AI console becomes composite field in the protocol. Earlier it was simple string field named "speech".
So, "speech" field now in the Fulfillment object. And you should change
response.Result.Speech
to
response.Result.Fulfillment.Speech
New release already in Nuget
Changed parser
In this release changed Json parser from fastJSON to Json.NET.
Also added some useful methods to the model classes for working with action parameters. Take a look:
response.Result.GetStringParameter("parameter_name", "optional_default_value");
response.Result.GetIntParameter("number")
response.Result.GetIntParameter("number", 17)
response.Result.GetFloatParameter("number")
response.Result.GetFloatParameter("number", 17f)
First library release
The API.AI .NET Core Library makes it easy to integrate the API.AI natural language processing API into your .NET application. Library provides simple programming interface for making text and voice requests to the API.AI service. See details on the api.ai website.