Versions and environments

You can create multiple versions of your agent and publish them to separate environments.

When you edit an agent, you are editing the draft agent. At any point, you can save the draft agent as an agent version, which is an immutable snapshot of your agent.

When you save the draft agent, it is published to the default environment. When you create agent versions, you can publish them to custom environments. You can create a variety of custom environments for:

  • testing
  • development
  • production
  • etc.

Production traffic

Always use agent versions for production traffic

A draft agent is updated every time a developer on your team makes a change. It is easy to break a draft agent unintentionally, especially if multiple people have write access to the agent. In addition, a recently edited draft agent may be inconsistent with the trained model, because training may have a delay or require manual execution.

You should always use agent versions for your production traffic. Draft agents should be tested before promoting them to production versions, and you can rollback to a previous version if any problems are discovered.

Consider possible agent errors while changing versions

If you change an agent version in your production environment while sessions are active, it may cause agent errors for some active sessions. These errors may happen if the previous and new versions are inconsistent with each other in a way that disrupts session state. Due to this, you should plan to change versions during down-time or off-peak hours.

Publish a version in a new environment

To publish an agent draft to a version and create a custom environment:

Console

  1. Go to the Dialogflow ES console.
  2. Select your agent near the top of the left sidebar menu.
  3. Click the settings button next to the agent name.
  4. Click the Environments tab.
  5. Click Publish a version.
  6. Add an optional description and click Next.
  7. Select +New Environment.

  8. Enter an environment name.

  9. Choose the fulfillment method for the environment.

  10. Select Text-to-speech settings for the environment.

  11. Click Publish.

  12. The environment information is now listed in the Custom environments section.

API

  1. Call the create method for the Version type to create a new agent version.
  2. Call the create method for the Environment type to create a new environment. Provide the agent version you just created to the agentVersion field.

Revert an environment to a previous version

You can revert an environment to a previous agent version:

Console

  1. Click an environment in the Custom environments section.
  2. The environment settings dialog opens.
  3. Click the option button for a previously published version in the Publishing History section.
  4. Click Revert to this version.
  5. The publishing history will be updated.

API

Call the patch/update method for the Environment type to update an environment. Provide the agent version you previously created to the agentVersion field.

Load a previous version to draft

Loading a previous version to draft overwrites the draft agent in the default environment with a selected agent version.

To load a previous version to draft:

Console

  1. Go to the Dialogflow ES console.
  2. Select your agent near the top of the left sidebar menu.
  3. Click the settings button next to the agent name.
  4. Click the Environments tab.
  5. Click View all versions in the Draft section.
  6. Click the option button for a version that you want to load to draft.
  7. Click Load to Draft.
  8. Click Yes, I'm sure.
  9. Reload any open console browser tabs, so they are refreshed with the latest agent data.

API

Call the patch/update method for the Environment type with the following inputs:

  • Use - as the environment ID to specify the default environment.
  • Set allowLoadToDraftAndDiscardChanges to true.
  • For the agentVersion field, supply the agent version that will overwrite the draft agent.

Export a version

To export a version, you need to load it to draft first, then export the agent.

Test your agent in an environment

You can use the API to test your agent in any of your custom environments. Call the detect intent method, but alter the endpoint URL by inserting environments/environment-name/users/-/ between agent and sessions.

For example, the following endpoint uses the "development" environment with an unspecified user:

"https://dialogflow.googleapis.com/v2/projects/my-project-id/agent/environments/development/users/-/sessions/123456789:detectIntent"

Environment-specific settings

Fulfillment and text-to-speech are configured by the environment, so the agent will use the environment's settings for these features.

For more information about how data is applied at various levels, see agent application levels.

Google Assistant

If you are using Actions on Google release environments, see the versioning limitations for the Dialogflow fulfillment library.

Mega agent

See how versions and environments work in mega agents.

Limitations

The following limitations apply:

  • Maximum number of environments per agent: 10
  • Maximum number of versions per agent: 1000