If you are not using one of the integration options, you must write code that directly interacts with the end-user. You must also directly interact with Dialogflow's API for each conversational turn to send end-user expressions and receive intent matches. The following diagram shows the processing flow when interacting with the API.
- The end-user types or speaks an expression.
- Your service sends this end-user expression to Dialogflow in a detect intent request message.
- 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.
- Your service performs actions as needed, like database queries or external API calls.
- Your service sends a response to the end-user.
- The end-user sees or hears the response.
Project setup and authentication
In most cases you should use the Dialogflow Console (visit documentation, open console) to build agents. You can follow the steps in the console quickstart page to create an agent. You can also use the Dialogflow API to build agents for advanced scenarios. Many concept pages focus on using the console to build agents, but they also provide links to relevant API types.
REST, gRPC, and client libraries
You can access the Dialogflow API via REST, gRPC, or one of the provided client libraries. If your desired programming language is supported by the client libraries, you should use the client library for your language. If your language is not supported, you should use REST for its simplicity or gRPC for its high performance. The client libraries are built on the gRPC protocol.
For the details on these options, see the reference pages.
A session represents a conversation between a Dialogflow agent and an end-user. You create a session at the beginning of a conversation and use it for each turn of the conversation. Once the conversation has ended, you discontinue using the session.
You should not use the same session for concurrent conversations with different end-users. Dialogflow maintains the currently active contexts for each active session. Session data is stored by Dialogflow for 20 minutes.
Each session is determined unique by a session ID. You create a new session by providing a new session ID in a detect intent request. A session ID is a string of at most 36 bytes in size. Your system is responsible for generating unique session IDs. They can be random numbers, hashed end-user identifiers, or any other values that are convenient for you to generate.
When you use the API for interactions,
your service interacts directly with the end-user.
For each conversational turn,
your service sends end-user expressions to Dialogflow by calling the
streamingDetectIntent method of the
Dialogflow responds with information about the matched intent,
the action, the parameters, and the response defined for the intent.
Your service performs actions as needed,
like database queries or external API calls,
and sends a message to the end-user.
This process continues until the conversation has ended.