{"id":20082413,"url":"https://github.com/googlesamples/assistant-sdk-nodejs","last_synced_at":"2025-06-10T13:34:52.144Z","repository":{"id":77425274,"uuid":"132518298","full_name":"googlesamples/assistant-sdk-nodejs","owner":"googlesamples","description":null,"archived":false,"fork":false,"pushed_at":"2018-11-27T19:33:01.000Z","size":14,"stargazers_count":93,"open_issues_count":6,"forks_count":27,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-06T00:38:06.460Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/googlesamples.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":"2018-05-07T21:27:51.000Z","updated_at":"2025-04-08T19:12:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"c9e74e52-d189-411b-87b8-08300316ac2c","html_url":"https://github.com/googlesamples/assistant-sdk-nodejs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fassistant-sdk-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fassistant-sdk-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fassistant-sdk-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fassistant-sdk-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/googlesamples","download_url":"https://codeload.github.com/googlesamples/assistant-sdk-nodejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlesamples%2Fassistant-sdk-nodejs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259085397,"owners_count":22803192,"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-13T15:43:17.355Z","updated_at":"2025-06-10T13:34:52.119Z","avatar_url":"https://github.com/googlesamples.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Assistant SDK for devices - Node.js\n\n## Setup\n\n1. Create or open a project in the [Actions Console](http://console.actions.google.com)\n1. Follow the instructions to [register a device model](https://developers.google.com/assistant/sdk/guides/service/python/embed/register-device)\n  1. Download `credentials.json`\n1. Install the [`google-oauthlib-tool`](https://github.com/GoogleCloudPlatform/google-auth-library-python-oauthlib) in a [Python 3](https://www.python.org/downloads/) virtual environment:\n\n```\npython3 -m venv env\nenv/bin/python -m pip install --upgrade pip setuptools\nenv/bin/pip install --upgrade \"google-auth-oauthlib[tool]\"\n```\n1. Use the [`google-oauthlib-tool`](https://github.com/GoogleCloudPlatform/google-auth-library-python-oauthlib) to generate credentials:\n\n```\nenv/bin/google-oauthlib-tool --client-secrets credentials.json \\\n                             --credentials devicecredentials.json \\\n                             --scope https://www.googleapis.com/auth/assistant-sdk-prototype \\\n                             --save\n```\n\n1. Run `cd google-assistant-grpc`\n1. Run `npm install`\n1. Run `node googleassistant.js`\n\n```Javascript\nconst GoogleAssistant = require('./googleassistant');\nconst deviceCredentials = require('./devicecredentials.json');\n\nconst CREDENTIALS = {\n  client_id: deviceCredentials.client_id,\n  client_secret: deviceCredentials.client_secret,\n  refresh_token: deviceCredentials.refresh_token,\n  type: \"authorized_user\"\n};\n\nconst assistant = new GoogleAssistant(CREDENTIALS);\n```\n\n## Usage\n\nThe `GoogleAssistant` class has several methods and helpers.\n\n* `.assist(string)` - Sends a string request to the Assistant. Returns a promise with the text response or device action if applicable.\n* `.setDeviceConfig(modelid, instanceid)` - Sets the device model and instance. This will need to be set with the model id you defined in the Actions Console to use device actions.\n* `.startConversation([initialPrompt])` - Starts a conversation with \"my test app\". Returns a promise with the text response.\n* `.startConversationWith(appName, [initialPrompt])` - Starts a conversation with an Assistant app. Returns a promise with the text response.\n* `.endConversation()` - Ends a conversation with an Assistant app. Returns a promise.\n* `.setLocale(locale)` - Changes the Assistant locale, in the format **en-US**.\n\n```Javascript\nassistant.assist('what time is it')\n  .then(({ text }) =\u003e {\n    console.log(text); // Will log \"It's 12:30\"\n  });\n```\n\nYou can chain together several requests and responses with Promises, as shown below.\n\n```Javascript\nassistant.assist('what is the weather')\n  .then(({ text }) =\u003e {\n    console.log(text);\n    return assistant.assist('what about the weather tomorrow')\n  })\n  .then(({ text }) =\u003e {\n    console.log(text);\n  });\n```\n\n## License\nSee `LICENSE`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglesamples%2Fassistant-sdk-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglesamples%2Fassistant-sdk-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglesamples%2Fassistant-sdk-nodejs/lists"}