{"id":19778868,"url":"https://github.com/dialogflow/dialogflow-dotnet-client","last_synced_at":"2025-04-30T21:31:18.291Z","repository":{"id":27402628,"uuid":"30879153","full_name":"dialogflow/dialogflow-dotnet-client","owner":"dialogflow","description":".NET framework for Dialogflow ","archived":false,"fork":false,"pushed_at":"2023-08-09T22:20:12.000Z","size":1161,"stargazers_count":70,"open_issues_count":28,"forks_count":51,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-04-29T02:06:54.800Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dialogflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-02-16T17:21:57.000Z","updated_at":"2024-04-29T02:06:54.801Z","dependencies_parsed_at":"2022-09-02T05:10:37.978Z","dependency_job_id":"1b171cee-31ce-4848-8b8d-723c982e0dbc","html_url":"https://github.com/dialogflow/dialogflow-dotnet-client","commit_stats":null,"previous_names":["api-ai/api-ai-net"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-dotnet-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-dotnet-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-dotnet-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-dotnet-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dialogflow","download_url":"https://codeload.github.com/dialogflow/dialogflow-dotnet-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224224789,"owners_count":17276428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T05:32:30.050Z","updated_at":"2024-11-12T05:32:51.536Z","avatar_url":"https://github.com/dialogflow.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DEPRECATED api.ai: .NET Library\n\n| Deprecated |\n|-------|\n| This Dialogflow client library and Dialogflow API V1 [have been deprecated and will be shut down on October 23th, 2019](https://blog.dialogflow.com/post/migrate-to-dialogflow-api-v2/). Please migrate to Dialogflow API V2 and the [v2 client library](https://cloud.google.com/dialogflow-enterprise/docs/reference/libraries/csharp) |\n\n[![Build Status](https://travis-ci.org/api-ai/apiai-dotnet-client.svg?branch=master)](https://travis-ci.org/api-ai/apiai-dotnet-client)\n[![Nuget Version](https://img.shields.io/nuget/v/ApiAiSDK.svg)](https://www.nuget.org/packages/ApiAiSDK/)\n\nThe api.ai .NET Library makes it easy to integrate the [API.AI natural language processing API](http://api.ai) into your .NET application. API.AI allows using voice commands and integration with dialog scenarios defined for a particular agent in API.AI.\n\nLibrary provides simple programming interface for making text and voice requests to the API.AI service. \n\n## Getting started\n\n### Installation\nLibrary can be installed with Nuget\n```\nPM\u003e Install-Package ApiAiSDK\n```\n\nOr can be downloaded as sources from the [Releases](https://github.com/api-ai/api-ai-net/releases) page.\n\n### Usage\n\nAssumed you already have API.AI account and have at least one agent configured. If no, please see [documentation](http://api.ai/docs/index.html) on the API.AI website.\n\nFirst, add following usages to your module:\n```csharp\nusing ApiAiSDK;\nusing ApiAiSDK.Model;\n```\n\nThen add `ApiAi` field to your class:\n```csharp\nprivate ApiAi apiAi;\n```\n\nNow you need to initialize `ApiAi` object with appropriate access keys and language.\n```csharp\nvar config = new AIConfiguration(\"YOUR_CLIENT_ACCESS_TOKEN\", SupportedLanguage.English);\napiAi = new ApiAi(config);\n```\n\nDone! Now you can easily do requests to the API.AI service \n* using `TextRequest` method for simple text requests\n    ```csharp\n    var response = apiAi.TextRequest(\"hello\");\n    ```\n\n* using `VoiceRequest` method for voice binary data in PCM (16000Hz, Mono, Signed 16 bit) format\n    ```csharp\n    var response = apiAi.VoiceRequest(voiceStream);\n    ```\n\nAlso see [unit tests](https://github.com/api-ai/api-ai-net/blob/master/ApiAiSDK.Tests/ApiAiTest.cs) for more examples.\n\n## Windows Phone 8\n\nWindows Phone version has some additional features such as system speech recognition for easy API.AI service integration.\nAfter installing the library you should add permissions for Internet and Sound recording to your app.\nCurrently, speech recognition is performed using Windows Phone System speech recognition. So, you must be sure languages you are using is installed on device (It can be checked on Settings-\u003espeech screen of device).\n\nTo use special features you need to use `AIService` class instead of `ApiAi` class. \n\n### Initialization \n\nFirst, you need to initialize AIConfiguration object with your keys and desired language.\n\n```csharp\nvar config = new AIConfiguration(\"client access token\", SupportedLanguage.English);\n```\n\nSecond, create AIService object using the configuration object.\n\n```csharp\nvar aiService = AIService.CreateService(config);\n```\n\nNow you need add handlers for OnResult and OnError events\n\n```csharp\naiService.OnResult += aiService_OnResult;\naiService.OnError += aiService_OnError;\n```\n\nAnd at the end call Initialization method\n\n```csharp\nawait aiService.InitializeAsync();\n```\n\nThe entire code snippet:\n\n```csharp\ntry\n{\n    var config = new AIConfiguration(\"client access token\", SupportedLanguage.English);\n\n    aiService = AIService.CreateService(config);\n    aiService.OnResult += aiService_OnResult;\n    aiService.OnError += aiService_OnError;\n    await aiService.InitializeAsync();\n}\ncatch (Exception e)\n{\n    // Some exception processing\n}\n```\n\n### Using API.AI\n\nNow you can use methods for listening and requesting results from server, all you need to call `StartRecognitionAsync` method (don't forget to use `await` operator, otherwise you will not be able to catch some processing exceptions)\n\n```csharp\ntry\n{\n    await aiService.StartRecognitionAsync();\n}\ncatch (Exception exception)\n{\n    // Some exception processing\n}\n```\n\n### Results processing\n\nResults will be passed to the `OnResult` handler, most of errors will be passed to the `OnError` handler. Don't forget to use dispatcher when working with UI, because of handlers can be called from the Background thread.\n\n```csharp\nvoid aiService_OnError(AIServiceException error)\n{\n    Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =\u003e\n    {\n        // sample error processing\n        ResultTextBlock.Text = error.Message;\n    });\n}\n\nvoid aiService_OnResult(ApiAiSDK.Model.AIResponse response)\n{\n    Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =\u003e\n    {\n        // sample result processing\n        ResultTextBlock.Text = response.Result.ResolvedQuery;\n    });\n}\n```\n\n## Universal Windows Platform\n\nUWP version of the library is similar to Windows Phone version except some differences in API.\nAfter installing the library you should add capabilities for **Internet(Client)** and **Microphone** to your app.\nCurrently, speech recognition is performed using `Windows.Media.SpeechRecognition` speech recognition. So, you must be sure languages you are using is installed on device.\nAPI for the platform uses async/await feature. So, you don't need to set up any callbacks.\n\nTo use special features you need to use `AIService` class instead of `ApiAi` class. \n\n### Initialization \n\nFirst, you need to initialize AIConfiguration object with your keys and desired language.\n\n```csharp\nvar config = new AIConfiguration(\"client access token\", SupportedLanguage.English);\n```\n\nSecond, create AIService object using the configuration object.\n\n```csharp\nvar aiService = AIService.CreateService(config);\n```\n\nAnd at the end call Initialization method\n\n```csharp\nawait aiService.InitializeAsync();\n```\n\nThe entire code snippet:\n\n```csharp\ntry\n{\n    var config = new AIConfiguration(\"client access token\", SupportedLanguage.English);\n    aiService = AIService.CreateService(config);\n    await aiService.InitializeAsync();\n}\ncatch (Exception e)\n{\n    // Some exception processing\n}\n```\n\n### Using API.AI\n\nNow you can use methods for listening and requesting results from server, all you need to call `StartRecognitionAsync` method (don't forget to use `await` operator, otherwise you will not be able to catch some processing exceptions)\n\n```csharp\ntry\n{\n    var response = await aiService.StartRecognitionAsync();\n}\ncatch (Exception exception)\n{\n    // Some exception processing\n}\n```\n\n### Results processing\n\nResults will be in the `response` variable.\n\n## Open Source Project Credits\n\n* JSON parsing implemented using [Json.NET](http://www.newtonsoft.com/json).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdialogflow%2Fdialogflow-dotnet-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdialogflow%2Fdialogflow-dotnet-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdialogflow%2Fdialogflow-dotnet-client/lists"}