[[["易于理解","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\u003eConversational Agents (Dialogflow CX) integrates with Git providers like GitHub, GitLab, and Bitbucket, allowing users to export agents to JSON and pull from a Git provider for agent restoration.\u003c/p\u003e\n"],["\u003cp\u003eThis integration allows leveraging Git source control features, such as agent change reviews, diff comparisons, and merges, within the context of Dialogflow CX agents.\u003c/p\u003e\n"],["\u003cp\u003eTo configure the integration, users must obtain an access token from their Git provider, store it in Secret Manager, and provide the secret resource to Conversational Agents (Dialogflow CX).\u003c/p\u003e\n"],["\u003cp\u003eThe Push feature exports the entire agent to the selected Git branch, overwriting existing files in the repository, while the Restore feature pulls data from the selected branch to overwrite the Conversational Agents (Dialogflow CX) agent.\u003c/p\u003e\n"],["\u003cp\u003eMultiple users can use this feature by working on different branches, pushing their changes, creating merge requests, and having another user review and restore the approved changes to the production agent branch.\u003c/p\u003e\n"]]],[],null,["# Git export/restore\n\n| **Note:** In February 2025, a new version of this integration was released. Users of the old version can provide tokens without using secrets. The documentation below applies primarily to the new version.\n\nConversational Agents (Dialogflow CX) integrates with multiple Git providers\n(GitHub, Gitlab, Bitbucket, and others).\nThis integration makes it easy to\n[export your agent to JSON](/dialogflow/cx/docs/reference/json-export)\nfor a push to a Git provider,\nand to pull from a Git provider for an\n[agent restore](/dialogflow/cx/docs/concept/agent#export).\nThe JSON exported format pushed to a Git provider\nis the expanded zip file contents of the exported agent.\n\nUsing this feature allows you to take advantage of\na Git provider source control features like:\n\n- Agent change reviews using code review tools\n- Examine agent diffs using diff tools\n- Merges\n\nLimitations\n-----------\n\nThe following limitations apply:\n\n- \\[Old integration version only\\] GitHub APIs have a limitation on the number of files that can be updated in a single commit. If the number of files exceeds 500, you may not be able to push to GitHub from Conversational Agents (Dialogflow CX). In such cases, you can export the agent as a zip and use the Git CLI on your machine to push the agent files to GitHub. This limitation will be addressed in a later Conversational Agents (Dialogflow CX) release.\n- GitHub private access [self-hosted](https://docs.github.com/en/enterprise-server/admin/overview/about-github-enterprise-server) repos are not supported, because Conversational Agents (Dialogflow CX) cannot access these repos.\n- The Git repository cannot contain any files other than the agent files exported by agent export. Any other files in the repository will be removed on every push.\n\nConfiguration\n-------------\n\nTo configure this feature,\nyou need to acquire an access token from your Git provider,\nstore it in Secret Manager,\nand provide the secret resource to Conversational Agents (Dialogflow CX):\n\n### Access token\n\nTo acquire an access token from your Git provider: \n\n### GitHub\n\nYou need to acquire a\n[GitHub personal token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)\nIf you use a fine-grained personal access token,\nyou need the following\n[permissions](https://docs.github.com/en/rest/overview/permissions-required-for-fine-grained-personal-access-tokens)\naccess:\n\n- **Repository Permissions \\\u003e Contents**: Read and write\n- **Repository Permissions \\\u003e Metadata**: Read-only (should be auto-selected after selecting Contents permission)\n\n### Gitlab\n\nYou need to acquire a\n[Gitlab personal access token](https://docs.gitlab.com/user/profile/personal_access_tokens/).\n\n### Bitbucket\n\nYou need to acquire a\n[Bitbucket access token](https://support.atlassian.com/bitbucket-cloud/docs/access-tokens/).\n\n### Secret Manager\n\nNow that you have an access token,\nyou need to create a secret for your token:\n\n1. [Enable the Secret Manager API](/secret-manager/docs/configuring-secret-manager).\n2. [Create a secret](/secret-manager/docs/create-secret-quickstart).\n\n### Conversational Agents (Dialogflow CX) configuration\n\nTo configure this integration for Conversational Agents (Dialogflow CX):\n\n1. Provide the Dialogflow service agent permission to access the access token secret in Secret Manager. Provide the `Secret Manager Secret Accessor` role to the `gcp-sa-dialogflow.iam.gserviceaccount.com` service account in your agent project. See [Grant access to Secret Manager secret](/secret-manager/docs/manage-access-to-secrets#grant-access).\n2. Open the Git integration configuration:\n - Conversational Agents console\n 1. Open the settings display by clicking the settings icon near the top right corner.\n 2. Scroll down and click **Add Git integration**.\n - Dialogflow CX console\n 1. Click the **Manage** tab.\n 2. Click **Git** in the **Testing \\& Deployment** section.\n 3. Click **Create new**.\n3. Provide configuration details:\n 1. Enter the following:\n - Display name for the GitHub connection.\n - Git repository URL (for example: `https://github.com/\u003cpath-to-repo\u003e.git`).\n - Add Git branches your agent will be interacting with. You can designate a branch as the default branch by clicking the star icon next to it.\n - Access token secret, which is the secret version you created in the form `projects/*/secrets/*/versions/*` for a specific version or `projects/*/secrets/*/versions/latest` for the latest version.\n 2. Click **Connect**.\n 3. It can take a minute for the Git service to be ready. The console will display notifications.\n\nPush and restore\n----------------\n\nOnce configured, you can push/pull your agent to/from Git.\n\nThe **Push** button is used to export your agent\nand make a commit to the Git branch selected in the Git branch dropdown.\nThis commit will consist of the entire agent and not specific changes,\nand will delete any existing files in the repository.\n\nUsers with **Dialogflow Reader** roles have the ability to push to Git\nrepositories. To prevent unwanted pushes, configure these agents with read-only\npersonal access tokens.\n\nThe **Restore** button is used to pull your agent data from the Git branch\nselected in the Git branch drop-down and restore your Conversational Agents (Dialogflow CX) agent from this\ndata. This will overwrite your agent in the same way that any agent restore\nbehaves.\n\nExample use case\n----------------\n\nThe following example illustrates how this feature can be used\nby multiple people to propose different agent changes to a production agent.\n\nConsider that your agent uses the following Git branches:\n\n- **Prod**: branch for your production agent\n- **Dev1**: branch for agent development\n- **Dev2**: another branch for agent development\n\nUser 1 wants to propose agent changes and takes the following steps:\n\n1. Export the production agent to a new agent.\n2. Make the desired changes to this agent copy.\n3. Test the changes.\n4. Push the altered agent to the **Dev1** branch.\n5. Create a merge request to the **Prod** branch.\n\nUser 2 wants to propose agent changes and takes the following steps:\n\n1. Export the production agent to a new agent.\n2. Make the desired changes to this agent copy.\n3. Test the changes.\n4. Push the altered agent to the **Dev2** branch.\n5. Create a merge request to the **Prod** branch.\n\nUser 3 reviews merge requests from both users and takes the following steps:\n\n1. Resolve conflicts.\n2. Commits approved changes.\n3. Restores the production Git branch to the production Conversational Agents (Dialogflow CX) agent."]]