Best practices

This document lists best practices for using Dialogflow. These guidelines are designed for greater efficiency and accuracy as well as optimal response times from the service.

Section Summary
Agent design Improve agent quality and performance.
Session client reuse Improve performance of detect intent API calls.
Batch updates to agent Prefer batch agent updates to many individual updates.

Agent design

Your agent design can greatly impact the quality and performance of your agent. See the Agent design guide for best practices focused on agent design.

Session client reuse

You can improve the performance of your application's detect intent API calls by reusing a client library session client instance for multiple requests.

The initial request made by an instance of a session client performs authentication, authorization, and access token generation. This processing can take multiple seconds. For further calls, the session client reuses the same access token for as long as it is valid (typically one hour). Once it expires, the session client refreshes the access token automatically, which can take multiple seconds to perform.

For optimal performance, you should reuse the same session client instance for all requests made by your application, and allow the client to refresh the access token as needed.

Batch updates to agent

If you are sending many individual agent update API requests over a short period of time, your requests may time out. These design-time API methods are not implemented to handle high update rates for a single agent.

Some data types have batch methods for this purpose:

  • Instead of sending many EntityTypes create, patch, or delete requests, use the batchUpdate or batchDelete methods.
  • Instead of sending many Intents create, patch, or delete requests, use the batchUpdate or batchDelete methods.