API を呼び出す際は事前に、GCP プロジェクトと認証を設定する必要があります。設定クイックスタートの手順を使用してください。
エージェントのビルド
ほとんどの場合、エージェントの作成には Dialogflow ES コンソール(ドキュメントを表示、コンソールを開く)を使用します。エージェントを作成するには、コンソール クイックスタート ページの手順を使用できます。また、高度なシナリオのエージェントを作成するには、Dialogflow API も使用できます。コンセプト ページの多くはコンソールを使用したエージェントの作成を中心に説明していますが、関連する API タイプへのリンクも提供します。
REST、gRPC、クライアント ライブラリ
Dialogflow API には、REST、gRPC、または指定されたクライアント ライブラリのいずれかを使用してアクセスできます。これらのオプションの詳細については、API の使用方法の概要をご覧ください。
各セッションは、システムによって生成されたセッション ID によって一意に判別されます。新しいセッションを作成するには、インテント検出リクエストで新しいセッション ID を指定します。セッション ID は最大 36 バイトの文字列です。システムによって固有のセッション ID が生成されます。この ID には、乱数、ハッシュ化されたエンドユーザー ID など、生成しやすい任意の値を使用できます。
インテントの検出
API を使用してインタラクションを行う場合、サービスがエンドユーザーと直接対話します。会話ターンごとに、サービスによって Sessions 型の detectIntent メソッドまたは streamingDetectIntent メソッドが呼び出され、Dialogflow にエンドユーザーの表現が送信されます。Dialogflow は、一致インテント、アクション、パラメータ、インテントに定義されたレスポンスに関する情報で応答します。サービスは必要に応じてアクション(データベース クエリや外部 API の呼び出し)を実行し、エンドユーザーにメッセージを送信します。このプロセスは、会話が終了するまで続きます。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eWhen not using pre-built integrations, direct interaction with Dialogflow's API is required for each conversational turn to process end-user input and receive intent matches.\u003c/p\u003e\n"],["\u003cp\u003eInteractions with the Dialogflow API follow a process where the service sends user expressions, Dialogflow returns intent data, and the service then performs actions and replies to the user.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, users need to set up a GCP project and authentication, which can be done through the provided setup quickstart.\u003c/p\u003e\n"],["\u003cp\u003eA session represents a conversation with an end-user, initiated with a unique session ID, and this ID should not be used for multiple concurrent conversations.\u003c/p\u003e\n"],["\u003cp\u003eTo interact, the service calls the \u003ccode\u003edetectIntent\u003c/code\u003e method to send the user's expressions to Dialogflow, which will respond with data about matched intents.\u003c/p\u003e\n"]]],[],null,["# API interactions\n\nIf you are not using one of the\n[integration](/dialogflow/docs/integrations)\noptions,\nyou must write code that directly interacts with the end-user.\nYou must also directly\n\ninteract with Dialogflow's API\n\nfor each conversational turn\nto send end-user expressions and receive intent matches.\nThe following diagram shows the processing flow when interacting with the API.\n\n1. The end-user types or speaks an expression.\n2. Your service sends this end-user expression to Dialogflow in a detect intent request message.\n3. Dialogflow sends a detect intent response message to your service. This message contains information about the matched intent, the action, the parameters, and the response defined for the intent.\n4. Your service performs actions as needed, like database queries or external API calls.\n5. Your service sends a response to the end-user.\n6. The end-user sees or hears the response.\n\nProject setup and authentication\n--------------------------------\n\nBefore calling the API,\nyou need to set up a GCP project and authentication.\nYou can follow the steps in the\n[Setup quickstart](/dialogflow/docs/quick/setup).\n\nAgent building\n--------------\n\nIn most cases you should use the Dialogflow ES console ([visit documentation](/dialogflow/docs/console), [open console](https://dialogflow.cloud.google.com)) to build agents.\nYou can follow the steps in the\n[console quickstart page](/dialogflow/docs/quick/build-agent)\nto create an agent.\nYou can also use the Dialogflow API to build agents for advanced scenarios.\nMany\n[concept pages](/dialogflow/docs/concepts)\nfocus on using the console to build agents,\nbut they also provide links to relevant API types.\n\nREST, gRPC, and client libraries\n--------------------------------\n\nYou can access the Dialogflow API via REST, gRPC,\nor one of the provided client libraries.\nFor the details on these options,\nsee the\n[API usage overview](/dialogflow/docs/reference/api-overview).\n\nSessions\n--------\n\n\nA *session* represents a conversation between a Dialogflow agent and an end-user.\nYou create a session at the beginning of a conversation\nand use it for each turn of the conversation.\nOnce the conversation has ended, you discontinue using the session.\n\n\nYou should not use the same session for\nconcurrent conversations with different end-users.\nDialogflow maintains the currently active contexts for each active session.\nSession data is stored by Dialogflow for 20 minutes.\n\n\nEach session is determined unique by a session ID generated by your system.\nYou create a new session by providing a new session ID in a\n[detect intent request](/dialogflow/docs/api-overview#detect-intent).\nA session ID is a string of at most 36 bytes in size.\nYour system is responsible for generating unique session IDs.\nThey can be random numbers, hashed end-user identifiers,\nor any other values that are convenient for you to generate.\n\nDetect intent\n-------------\n\n\nWhen you use the API for interactions,\nyour service interacts directly with the end-user.\nFor each conversational turn,\nyour service sends end-user expressions to Dialogflow by calling the\n`detectIntent` or `streamingDetectIntent` method of the\n[`Sessions`](/dialogflow/docs/reference/common-types#sessions)\ntype.\nDialogflow responds with information about the matched intent,\nthe action, the parameters, and the response defined for the intent.\nYour service performs actions as needed\n(for example, database queries or external API calls)\nand sends a message to the end-user.\nThis process continues until the conversation has ended.\n\nYou can find examples of calling detect intent in the\n[API quickstart page](/dialogflow/docs/quick/api)\nand the\n[how-to pages](/dialogflow/docs/how)."]]