{"id":13879867,"url":"https://github.com/dialogflow/dialogflow-ruby-client","last_synced_at":"2025-06-26T20:10:31.482Z","repository":{"id":82729643,"uuid":"27089728","full_name":"dialogflow/dialogflow-ruby-client","owner":"dialogflow","description":"Ruby SDK for Dialogflow","archived":false,"fork":false,"pushed_at":"2020-09-09T09:43:32.000Z","size":99,"stargazers_count":141,"open_issues_count":9,"forks_count":29,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-30T21:39:07.596Z","etag":null,"topics":["api-ai","apiai","natural-language-processing","natural-language-understanding","nlp","nlu","ruby","ruby-sdk","sdk"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-24T18:51:25.000Z","updated_at":"2023-12-05T08:46:37.000Z","dependencies_parsed_at":"2023-03-30T05:34:38.371Z","dependency_job_id":null,"html_url":"https://github.com/dialogflow/dialogflow-ruby-client","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/dialogflow/dialogflow-ruby-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-ruby-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-ruby-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-ruby-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-ruby-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dialogflow","download_url":"https://codeload.github.com/dialogflow/dialogflow-ruby-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dialogflow%2Fdialogflow-ruby-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262137149,"owners_count":23264675,"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":["api-ai","apiai","natural-language-processing","natural-language-understanding","nlp","nlu","ruby","ruby-sdk","sdk"],"created_at":"2024-08-06T08:02:36.732Z","updated_at":"2025-06-26T20:10:31.468Z","avatar_url":"https://github.com/dialogflow.png","language":"Ruby","readme":"# DEPRECATED The API.AI ruby gem\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/ruby) |\n\n[![Gem Version](https://badge.fury.io/rb/api-ai-ruby.svg)](https://badge.fury.io/rb/api-ai-ruby)\n\nA Ruby SDK to the https://api.ai natural language processing service.\n\n## Installation\n    gem install api-ai-ruby\n\n## Basic Usage\n\nJust pass correct credentials to **ApiAiRuby::Client** constructor\n\n```ruby\nclient = ApiAiRuby::Client.new(\n    :client_access_token =\u003e 'YOUR_CLIENT_ACCESS_TOKEN'\n)\n```\nAfter that you can send text requests to the https://api.ai with command\n\n```ruby\nresponse = client.text_request 'hello!'\n```\n\nOr try to invocate intent via defined '[event](https://docs.api.ai/docs/concept-events)':\n\n```ruby\n\nresponse_zero = client.event_request 'MY_CUSTOM_EVENT_NAME';\nresponse_one = client.event_request 'MY_EVENT_WITH_DATA_TO_STORE', {:param1 =\u003e 'value'}\nresponse_two = client.event_request 'MY_EVENT_WITH_DATA_TO_STORE', {:some_param =\u003e 'some_value'}, :resetContexts =\u003e true\n\n```\n\n**voice_request** and **text_request** methods returns symbolized https://api.ai response. Structure of response can be found at https://docs.api.ai/docs/query#response.\n\n## Advanced usage\n\nDuring client instantiating you can additionally set parameters like **api url**, request **language** and **version** (more info at https://docs.api.ai/docs/versioning, https://docs.api.ai/docs/languages)\n\n```ruby\nApiAiRuby::Client.new(\n    client_access_token: 'YOUR_ACCESS_TOKEN',\n    api_lang: 'FR',\n    api_base_url: 'http://example.com/v1/',\n    api_version: 'YYYYMMDD',\n    api_session_id: 'some_uuid_or_whatever'\n)\n```\n\nAnd you also can send additional data to server during request, use second parameter of **text_request** and **voice_request** methods to do that\n\n```ruby\n    response = client.text_request 'Hello', :contexts =\u003e ['firstContext'], :resetContexts =\u003e true\n    response = client.voice_request file, :timezone =\u003e 'America/New_York'\n```\n\nMore information about possible parameters can be found at https://docs.api.ai/docs/query page\n\n## User Entities\n\nAnother possibility is to send and retrieve [custom entities](https://docs.api.ai/docs/userentities) to the server.\n\nYou can do it along with **query** request\n```ruby\nclient.text_request 'call Mozart', entities: [\n    {\n        name: 'contacts',\n        entries: [\n            ApiAiRuby::Entry.new('Mozart', %w(Mozart Wolfgang)),\n            ApiAiRuby::Entry.new('Salieri', %w(Salieri Antonio))\n        ]\n    }\n]\n\n# the same without ApiAiRuby::Entry wrapper\n\nclient.text_request 'call Mozart', entities: [\n    {\n        name: 'contacts',\n        entries: [\n            {value: 'Mozart', synonyms: %w(Mozart Wolfgang)},\n            {value: 'Salieri', synonyms: %w(Salieri Antonio)}\n        ]\n    }\n]\n\n```\n\nOr with separate **create_user_entities_request** object with full CRUD support:\n\n```ruby\n\n# preparations\nentries_composers = [\n    ApiAiRuby::Entry.new('Mozart', %w(Mozart Wolfgang)),\n    ApiAiRuby::Entry.new('Salieri', %w(Salieri Antonio))\n]\n\nentries_unknown = [\n    ApiAiRuby::Entry.new('John Doe', %w(John Unknown)),\n    ApiAiRuby::Entry.new('Jane Doe', %w(Jane))\n]\n\nentity_contacts = ApiAiRuby::Entity.new('contacts', entries_composers)\n\n# let's go\nuer = client.create_user_entities_request\nuer.create(entity_contacts) # or uer.create([entity1, entity2...])\n\nclient.text_request 'call Mozart' # will work\n\nuer.update('contacts', entries_unknown)\n\nclient.text_request 'call Mozart' # will NOT work\nclient.text_request 'call John' # will work\n\nuer.retrieve('contacts') # will return current state of user entity\nuer.delete('contacts') # will remove user entities for given session    \n\n```\n## Context\nAlso SDK has full support of [contexts](https://docs.api.ai/docs/contexts) API.AI endpoint with special object, called ```contexts_request```\nUsage is simple:\n```ruby\n\n# some preparations\nlifespan = 5\nparameters = {\n  :param_name =\u003e 'param_value'\n}\nname = 'test_context'\n\n# you can create context using built-in model ApiAiRuby::Context\ntest_context = ApiAiRuby::Context.new(name, lifespan, parameters)\nanother_test_context = ApiAiRuby::Context.new('another_test_context')\none_more_test_context = ApiAiRuby::Context.new('one_more_test_context', 4)\n\n# ok, we are ready\n\ncontext_request = @client.create_contexts_request\n\n# there are different options to be used with .create\n\ncontext_request.create(test_context)\ncontext_request.create([another_test_context, one_more_test_context])\ncontext_request.create('one_more_super_final_mega_context')\n\ncontext_request.retrieve('test_context') # will return you single context or nothing\ncontext_request.list() # will return you list of all contexts used in current session\ncontext_request.delete('test_context') # will remove single context\ncontext_request.delete() # will remove all context in session\n\n```\n\n# Timeouts\n**ApiAiRuby::Client** uses the [http gem](https://github.com/httprb/http) under the hood.  You can use ```timeout_options``` on the client to set these.\n```ruby\nApiAiRuby::Client.new(\n    client_access_token: 'YOUR_ACCESS_TOKEN',\n    api_lang: 'FR',\n    api_base_url: 'http://example.com/v1/',\n    api_version: 'YYYYMMDD',\n    api_session_id: 'some_uuid_or_whatever',\n    timeout_options: [:global, { write: 1, connect: 1, read: 1 }]\n)\n```\n\nPlease see the [httprb wiki on timeouts](https://github.com/httprb/http/wiki/Timeouts) for more information.\n\n\n# Error handling\n**ApiAiRuby::Client** currently able to raise two kind of errors: **ApiAiRuby::ClientError** (due to configuration mismatch) and **ApiAiRuby::RequestError** in case of something goes wrong during request. For both kind of errors you can get **error.message** (as usual) and **ApiAiRuby::RequestError** can additionally give you code of server error (you can get it with **error.code**)\n\n\n# Changelog\n\n## 2.0.0\n### Breaking:\n- http gem dependency updated to 2.0, it does no longer raise `Errno::ETIMEDOUT`. Thanks to @tak1n\n\n## 1.3.0 \n\n### Non-breaking:\n- contexts endpoint support (https://docs.api.ai/docs/contexts)\n- better RDoc\n\n### Breaking:\n- ApiAiRuby::Client::user_entities_request renamed to ApiAiRuby::Client::create_user_entities_request\n- ApiAiRuby::Entity::addEntry renamed to ApiAiRuby::Entity::add_entry\n\n## Previous\n* 1.2.3 - events support\n* 1.2.2 - added configurable timeouts for requests (thanks [bramski](https://github.com/bramski))\n* 1.2.1 - fixed UTF-8 in text-requests\n* 1.2.0 - added configurable session_id and full userEntities support\n* 1.1.4 - removed unused dependency and updated default API version\n* 1.1.3 - fixed non-correctly serialized parameters in new contexts during query send process\n* 1.1.2 - fixed compatibility with ruby version less then 2.1.6\n\n## How to make contributions?\nPlease read and follow the steps in the [CONTRIBUTING.md](CONTRIBUTING.md).\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","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdialogflow%2Fdialogflow-ruby-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdialogflow%2Fdialogflow-ruby-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdialogflow%2Fdialogflow-ruby-client/lists"}