Versions and Environments BETA

Versions and Environments in Dialogflow allow you to deploy multiple versions of your agent to separate, customizable instances of environments, depending on your needs. This section goes over how to create a new version of your agent, how to create and publish to an environment, and how to change which version is being used in the environment.

You can set up separate environments for testing, development, and production, and control which version of your agent is used in each environment.

Environments

Environments are instances that serve versions of your agent. With this feature, a version of your agent can be tested in one environment without affecting the production version of your agent.

You have the option to create a new environment when you publish a version.

Versions

A version is an immutable copy of the current state of your agent, which you can then publish to an environment. When a new version is created, a snapshot of the intents and entities in your current agent is used.

Prior to publishing any changes to a version, the current version of your agent containing edits is called a draft. This draft is the state of your agent that you publish to an environment.

Publish a version and create an environment

To publish your draft to a version and create a custom environment, follow these steps:

  1. Click on the gear icon settings for the agent.
  2. Click on the Environments tab.
  3. Click PUBLISH A VERSION.
  4. Add an optional description and click NEXT.
  5. Click on the Environment menu.
  6. Choose +New Environment.
  7. Enter an environment name.
  8. Choose the fulfillment method you'd like to use for your agent.
  9. Click PUBLISH.

You can view environment information by clicking on a list item under Custom environments.

Revert an environment to a previous version

At some point, you may need to load a previous version to an environment. The history of versions published to the environment can be seen under the Publishing History section of the environment details.

If you need to revert an environment to a previous version, follow these steps:

  1. Click on an environment under Custom environments.
  2. Click the option icon more_vert for a previously published version under Publishing History.
  3. Click on Revert to this version.

The publishing history will be updated and show the revert to the previous version.

Load a previous version to draft

Draft is the current version of your agent that is being edited. Under certain circumstances, like if irreparable changes were made to an agent, you may want to load a previous version.

To load a previous version to draft, follow these steps:

  1. Click on an environment under Custom environments.
  2. Click on the option icon more_vert for a previously published version under Publishing History.
  3. Click Load to Draft.

  4. Click YES, I'M SURE.

Test your agent in an environment

You can use a cURL command to test your agent in any of your custom environments. To test your agent in draft or in a specific environment, you'll need to use Dialogflow's API. You can easily copy the cURL for a query from the Dialogflow simulator.

To test an agent you published to an environment, follow these steps:

  1. Type a query in the Dialogflow simulator on the right side of the page and press enter.
  2. Click COPY CURL in the USER SAYS section.

    The copied data should look something like this:

    curl \
    -H "Content-Type: application/json; charset=utf-8" \
    -H "Authorization: Bearer <generated token>" \
    -d "{
    "queryInput": {
      "text": {
        "text": "How are you?",
        "languageCode": "en"
      }
    },
    "queryParams": {
      "timeZone": "America/Los_Angeles"
    }
    }" \
    "https://dialogflow.googleapis.com/v2beta1/projects/small-talk-dfghk/agent/sessions/e5472b8a-9feb-43f1-8213-648215960d22:detectIntent"
    

In order to query an environment, you'll need to alter the URL at the end of the copied cURL. Using the example above, environments/development/users/-/ was added between agent and sessions to query an environment named "Development". The result looks like this:

"https://dialogflow.googleapis.com/v2beta1/projects/small-talk-dfghk/agent/environments/development/users/-/sessions/e5472b8a-9feb-43f1-8213-648215960d22:detectIntent"