会話型アクションのサポートは 2023 年 6 月 13 日に終了しました。詳細については、
会話型アクションの廃止をご覧ください。
Actions API
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Actions API は、アクションの作成、管理、テストに役立つエンドポイントを提供します。
クライアント ライブラリ(Node.js)
Actions API RESTful サービスは、サーバーに直接 HTTP リクエストを送信することでも使用できますが、Node.js からエンドポイントに簡単にアクセスできるようにするクライアント ライブラリも提供しています。Actions API クライアント ライブラリを使用すると、さまざまなエンドポイントを使用してアクションの管理とテストを行うことができます。
たとえば、以下のコードは writePreview
エンドポイントを呼び出し、指定されたモデルに基づいてユーザーのプロジェクト プレビューを更新します。
import {ActionsSdkClient} from '@assistant/actions';
import { promisify } from 'util';
import * as stream from 'stream';
const PROJECT_ID = '<PROJECT_ID>';
const VERSION = 123;
const projectPath = `projects/${PROJECT_ID}`;
const versionPath = `projects/${PROJECT_ID}/versions/${VERSION}`;
async function publishPreview(projectPath, versionPath) {
const request = {
parent: projectPath,
previewSettings: {sandbox: {value: true}},
submittedVersion: {version: versionPath}
};
const client = new ActionsSdkClient();
const stream = client.writePreview(()=>{});
stream.write(request);
stream.end();
const finished = promisify(stream.finished);
await finished(stream);
}
Actions API Node.js クライアント ライブラリのインストール手順とリファレンス マテリアルについては、ライブラリと Actions API REST リファレンスのドキュメントをご覧ください。
要件
Actions API に対して行われるリクエストには、次の要件が適用されます。
リクエスト ペイロードのサイズ
Actions API に対するリクエストは 10 MB 以下である必要があります。例
クライアント ストリーミング エンドポイント。ストリーム内の各リクエストは 10 MB である必要があります。
できます。
ペイロードが 10 MB を超えると、アクションから 400
エラーが返されます。
使用します。
ベスト プラクティス
次のベスト プラクティスは、
Actions API を使用します。
ユーザー向けにツールやアプリケーションを作成する場合、
クライアント プロジェクトではなく、プロジェクトに課金して割り当て上限として使用します。
課金と割り当ての目的でプロジェクトを指定するには、
x-goog-user-project
リクエスト ヘッダー。
有効な値 |
既存のプロジェクトのプロジェクト ID
Google Cloud プロジェクト |
例 |
x-goog-user-project: my-project |
詳細 |
ヘッダーで指定されたプロジェクトが割り当て上限として使用され、課金対象
請求が行われる可能性があります
|
user-agent
リクエスト ヘッダーを使用して、適切なユーザー エージェントを設定します。この
リクエストがパートナーから発信されたかどうかを API が判断するのに役立ちます。
既知の制限事項
このセクションでは、Actions API の既知の制限事項について説明します。
クライアント ストリーミング エンドポイントのタイムアウト
この制限は、クライアント ストリーミングに対して行う HTTP リクエストにのみ適用されます。
提供しますクライアント ライブラリを使用して行われたリクエストは、
この制限の影響を受ける。
HTTP リクエストを使用して WritePreview
、CreateVersion
、または WriteDraft
を呼び出す場合、
リクエストされていないリクエストを処理できるように、タイムアウトを
成功です。
200
以外のステータス コードを指定するレスポンス ヘッダーを受け取った場合、
コードは一定の時間が経過したらストリームを終了する必要があります。この問題
クライアント ストリーミング エンドポイントにのみ影響します。たとえば、gactions
ツールは、
5 秒のタイムアウトがあります。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-26 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-26 UTC。"],[[["\u003cp\u003eThe Actions API offers endpoints for building, managing, and testing Actions.\u003c/p\u003e\n"],["\u003cp\u003eA Node.js client library simplifies interactions with the API, offering easier access to endpoints for managing and testing your Action.\u003c/p\u003e\n"],["\u003cp\u003eRequests to the Actions API must be 10 MB or less, including those made to client streaming endpoints.\u003c/p\u003e\n"],["\u003cp\u003eSetting the \u003ccode\u003ex-goog-user-project\u003c/code\u003e request header enables billing and quota management for user projects.\u003c/p\u003e\n"],["\u003cp\u003eWhen using HTTP requests with client streaming endpoints like \u003ccode\u003eWritePreview\u003c/code\u003e, it's recommended to implement a timeout to handle potential unsuccessful requests.\u003c/p\u003e\n"]]],["The Actions API facilitates Action development, management, and testing. A Node.js client library simplifies interaction with API endpoints. For instance, `writePreview` updates a project preview. Requests must be under 10MB, with the `x-goog-user-project` header recommended for billing and quota purposes. The `user-agent` header is advised for partner identification. Direct HTTP calls to streaming endpoints like `WritePreview` have timeout considerations, though the client library mitigates this.\n"],null,["# Actions API\n\nThe Actions API provides endpoints to help build, manage, and test your Action.\n\nClient Library (Node.js)\n------------------------\n\nWhile you can use the Actions API RESTful service by making direct HTTP requests to the server, we provide a client library that makes it easier to access the endpoints from Node.js. The [Actions API client library](https://github.com/actions-on-google/assistant-actions-nodejs) allows you to manage and test your Action using a variety of endpoints.\n\nFor example, the code below makes a call to the [`writePreview`](/assistant/actions/api/reference/rest/v2/projects.preview/write) endpoint to update a user's project preview based on the provided model: \n\n import {ActionsSdkClient} from '@assistant/actions';\n import { promisify } from 'util';\n import * as stream from 'stream';\n\n const PROJECT_ID = '\u003cPROJECT_ID\u003e';\n const VERSION = 123;\n\n const projectPath = `projects/${PROJECT_ID}`;\n const versionPath = `projects/${PROJECT_ID}/versions/${VERSION}`;\n\n async function publishPreview(projectPath, versionPath) {\n const request = {\n parent: projectPath,\n previewSettings: {sandbox: {value: true}},\n submittedVersion: {version: versionPath}\n };\n\n const client = new ActionsSdkClient();\n const stream = client.writePreview(()=\u003e{});\n stream.write(request);\n stream.end();\n const finished = promisify(stream.finished);\n await finished(stream);\n }\n\nFor installation instructions and reference material for the Actions API Node.js client library, see the [library](/assistant/actions/api/(https:/github.com/actions-on-google/assistant-actions-nodejs)) and [Actions API REST reference](/assistant/actions/api/reference/rest) documentation.\n\nRequirements\n------------\n\nThe following requirements apply to requests made to the Actions API.\n\n### Request payload size\n\nRequests made to the Actions API must be 10 MB or less. This includes\nclient streaming endpoints, where each request in the stream must be 10 MB\nor less.\n\nIf your payload exceeds 10 MB, you should receive a `400` error from the Actions\nSDK server.\n\nBest practices\n--------------\n\nThe following best practices are strongly recommended when\nyou use the Actions API.\n\n### Set the x-goog-user-project request header\n\nWhen building a tool or application for your users, you may want a user's\nproject to be billed and used for quota limits, rather than your client project.\nTo specify a project for billing and quota purposes, set the\n`x-goog-user-project` request header.\n\n|--------------|------------------------------------------------------------------------------------------------------------------|\n| Valid Values | The [Project ID](/docs/overview#projects) for an existing Google Cloud project |\n| Example | `x-goog-user-project: my-project` |\n| Details | The project specified in the header is used for quota limits and billed for charges associated with the request. |\n\n### Set the user-agent request header\n\nSet an appropriate user agent using the `user-agent` request header. This\nhelps the API determine if requests originate from partners.\n\nKnown limitations\n-----------------\n\nThis section describes known limitations of the Actions API.\n\n### Timeout for client streaming endpoints\n\nThis limitation only applies to HTTP requests you make to client streaming\nendpoints. Requests made using the [client library](#client-library) are not\naffected by this limitation.\n\nIf you are using HTTP requests to call `WritePreview`, `CreateVersion`, or `WriteDraft`, we\nrecommend that you implement a timeout to handle requests that are not\nsuccessful.\n\nIf you receive a response header that specifies a status code other than `200`,\nyour code should terminate the stream after a certain period of time. This issue\nonly affects client streaming endpoints. For example, the `gactions` tool,\nwhich uses the Actions API, has a 5-second timeout."]]