[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\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)."]]