{"id":19778861,"url":"https://github.com/dialogflow/dialogflow-cordova-client","last_synced_at":"2025-04-30T21:31:17.508Z","repository":{"id":23404777,"uuid":"26766988","full_name":"dialogflow/dialogflow-cordova-client","owner":"dialogflow","description":"Cordova library for Dialogflow ","archived":false,"fork":false,"pushed_at":"2019-02-20T18:52:22.000Z","size":18625,"stargazers_count":42,"open_issues_count":28,"forks_count":23,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-06-21T14:18:09.176Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-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}},"created_at":"2014-11-17T16:58:29.000Z","updated_at":"2021-12-07T21:41:05.000Z","dependencies_parsed_at":"2022-08-26T09:31:57.272Z","dependency_job_id":null,"html_url":"https://github.com/dialogflow/dialogflow-cordova-client","commit_stats":null,"previous_names":["api-ai/api-ai-cordova"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-cordova-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-cordova-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-cordova-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-cordova-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dialogflow","download_url":"https://codeload.github.com/dialogflow/dialogflow-cordova-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224224786,"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:21.450Z","updated_at":"2024-11-12T05:32:51.285Z","avatar_url":"https://github.com/dialogflow.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DEPRECATED api-ai-cordova\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](https://cloud.google.com/dialogflow-enterprise/docs/migrating). |\n\n[![Build Status](https://travis-ci.org/api-ai/api-ai-cordova.svg?branch=master)](https://travis-ci.org/api-ai/api-ai-cordova)\n\nPlugin makes it easy to integrate your Cordova application with [api.ai](http://api.ai) natural language processing service. This plugin supports Android and iOS mobile operation systems.\n\nProject on Github [https://github.com/api-ai/api-ai-cordova](https://github.com/api-ai/api-ai-cordova)  \nPage in NPM [https://www.npmjs.com/package/cordova-plugin-apiai](https://www.npmjs.com/package/cordova-plugin-apiai)  \nGithub issues [https://github.com/api-ai/api-ai-cordova/issues](https://github.com/api-ai/api-ai-cordova/issues)  \nDemo application sources [https://github.com/api-ai/api-ai-cordova-sample](https://github.com/api-ai/api-ai-cordova-sample)  \n\n* [Installation](#installation)\n* [Usage](#usage)\n* [API](#api)\n    - [Request Options](#request-options)\n* [Supported Languages](#supported-languages)\n* [Promise-Based Wrapper](#promise-based-wrapper)\n\n\n# Installation\n* Make sure that [Cordova CLI](http://cordova.apache.org/#getstarted) is installed\n* Install api.ai plugin with Cordova CLI:\n```shell\ncordova plugin add cordova-plugin-apiai\n```\n\n# Usage\nAdd to your **index.js** file (typically in **js** folder) in function **onDeviceReady** following code\n```javascript\nApiAIPlugin.init(\n        {\n            clientAccessToken: \"YOUR_CLIENT_ACCESS_TOKEN\", // insert your client access key here\n            lang: \"en\" // set lang tag from list of supported languages\n        }, \n        function(result) { /* success processing */ },\n        function(error) { /* error processing */ }\n    );\n```\n\nAdd to your page with mic button function to make voice requests:\n```javascript\nfunction sendVoice() {\n    try {     \n      ApiAIPlugin.requestVoice(\n        {}, // empty for simple requests, some optional parameters can be here\n        function (response) {\n            // place your result processing here\n            alert(JSON.stringify(response));\n        },\n        function (error) {\n            // place your error processing here\n            alert(error);\n        });                \n    } catch (e) {\n        alert(e);\n    }\n}\n```\n\nIf you want to create voice level visualization use function ```levelMeterCallback``` to set callback for processing soundLevel:\n```javascript\nApiAIPlugin.levelMeterCallback(function(level) {\n   console.log(level);\n   // add visualization code here\n});\n```\n\nIf you want to handle start and stop listening events, add appropriate handlers:\n```javascript\nApiAIPlugin.setListeningStartCallback(function () {\n    console.log(\"listening started\");\n});\n\nApiAIPlugin.setListeningFinishCallback(function () {\n    console.log(\"listening stopped\");\n});\n```\n\n**Please note**, that handlers must be added before ```ApiAIPlugin.requestVoice``` call, like here:\n```javascript\nfunction sendVoice() {\n    try {    \n\n      // !!!\n      ApiAIPlugin.levelMeterCallback(function(level) {\n         console.log(level);\n      }); \n\n      ApiAIPlugin.requestVoice(...\n```\n\nThen add call ```sendVoice``` function from your button's ```onclick```:\n```html\n\u003cdiv onclick=\"sendVoice();\"\u003eMic\u003c/div\u003e\n```\n\nIf you want make text requests add the following code:\n```javascript\nfunction sendText(query_text) {\n    try {\n        ApiAIPlugin.requestText(\n            {\n                query: query_text\n            },\n            function (response) {\n                // place your result processing here\n                alert(JSON.stringify(response));\n            },\n            function (error) {\n                // place your error processing here\n                alert(error);\n            });\n    } catch (e) {\n        alert(e);\n    }\n}\n```\n\nAlso you can use function to cancel current api.ai request:\n```javascript\nApiAIPlugin.cancelAllRequests();\n```\n\n# API\n```javascript\n// Initialize plugin\n//  options - JSON object - `{\n//                              clientAccessToken: \"your_access_token\",\n//                              lang: \"one_of_supported_languages\"\n//                           }`\n//  success - Function (optional) - callback for initialization success: function () {}\n//  error - Function (optional) - callback for initialization error: function (error) {}\nApiAIPlugin.init(options, success, error)\n\n// Start listening, then make voice request to api.ai service\n//  options - JSON object - voice request options (reserved for future use)\n//  success - Function (optional) - callback for request success `function (response) {}` where response is Object \n//  error - Function (optional) - callback for request error `function (error) {}` where error is String\nApiAIPlugin.requestVoice(options, success, error)\n\n// Make text request to api.ai service\n//  options - JSON object - `{ query: \"queryText\" }`\n//  success - Function (optional) - callback for request success `function (response) {}` where response is Object \n//  error - Function (optional) - callback for request error `function (error) {}` where error is String\nApiAIPlugin.requestText(options, success, error)\n\n// Set callback for sound level. Need to call only once after initialization\n//  callback - Function - function must be `function(level) { }`, level is float value from 0 to 1\nApiAIPlugin.levelMeterCallback(callback)\n\n// Cancel all pending requests\nApiAIPlugin.cancelAllRequests()\n\n// Stop current listening process and send request to server\nApiAIPlugin.stopListening()\n\n// Set callback for listening started event\n//  callback - Function - must be simple function without arguments: function () {} \nApiAIPlugin.setListeningStartCallback(callback)\n\n// Set callback for listening finished callback\n//  callback - Function - must be simple function without arguments: function () {}\nApiAIPlugin.setListeningFinishCallback(callback)\n\n// Set callback for getting partial recognition results (Available only on Android platform!)\n// callback - Function - must be `function(str) { }` with string argument\n// You can get the json array of strings with partial recognition results\nApiAIPlugin.setPartialResultsCallback(callback)\n```\n\n## Request Options\nThe `options` parameter may contains following fields:\n* `query` - text query, only appliable to `requestText` function\n* `contexts` - list of strings or objects, input context for the request (See [Contexts Quick Start](http://api.ai/docs/getting-started/quick-start-contexts.html) for more information about Contexts)\n    strings:\n    ```javascript\n    contexts: [ \"weather\", \"home\" ]\n    ```\n    objects:\n    ```javascript\n    contexts: [ { name: \"weather\", parameters: { location: \"London\" } }, { name: \"home\"} ]\n    ```\n\n* `resetContexts` - boolean flag, set it to true to reset current active contexts\n    ```javascript\n    resetContexts: true\n    ```\n\n* `entities` - array of entities that replace developer defined entities for this request only. The entity(ies) need to exist in the developer console. Each entity is the pair of name and `entries` array. Entries array contains one or more items with `value` and `synonyms` fields.\n    ```javascript\n    entities: [\n      {\n        name: \"dwarfs\",\n        entries: [\n          {\n            value: \"Ori\",\n            synonyms: [\n              \"Ori\",\n              \"Nori\"\n            ]\n          },\n          {\n            value: \"bifur\",\n            synonyms: [\n              \"Bofur\",\n              \"Bombur\"\n            ]\n          }\n        ]\n      }\n    ]\n    ```\n* `context` also may have `lifespan` property - integer number defining number of requests the context will influence\n    ```javascript\n    {\n        name: \"weather\",\n        lifespan: 2,\n        parameters: {\n            location: \"London\"\n        }\n    }\n    ```\n\nFor many samples see [tests](https://github.com/api-ai/api-ai-cordova/blob/master/tests/tests.js)\n\n# Supported Languages\n* en\n* es\n* ru\n* de\n* pt\n* pt-BR\n* es\n* fr\n* it\n* ja\n* ko\n* zh-CN\n* zh-HK\n* zh-TW\n\n# Promise-Based Wrapper\nThe promise-based wrapper was added for ease of use and better interoperability with other JavaScript code. Wrapper implemented using the [Q](https://github.com/kriskowal/q) library. You can use the wrapper through `ApiAIPromises` module. For example:\n```javascript\nApiAIPromises.requestText(\n{\n    query: \"Hello\"\n})\n.then(function (response) {\n    // some response processing\n    console.log(response.result.action);\n})\n.fail(function (error) {\n    // some error processing\n    console.log(error);\n});\n```\n\nMore samples you can find in the [tests](https://github.com/api-ai/api-ai-cordova/blob/master/tests/tests.js) module.\n\n## License\nSee [LICENSE](LICENSE).\n\n## Terms\nYour use of this sample is subject to, and by using or downloading the sample files you agree to comply with, the [Google APIs Terms of Service](https://developers.google.com/terms/).\n\nThis is not an official Google product.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdialogflow%2Fdialogflow-cordova-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdialogflow%2Fdialogflow-cordova-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdialogflow%2Fdialogflow-cordova-client/lists"}