[[["易于理解","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\u003eCustom entities can be created to match data specific to your agent, such as defining a \u003ccode\u003evegetable\u003c/code\u003e entity for a grocery store agent.\u003c/p\u003e\n"],["\u003cp\u003eEntities should be defined before adding training phrases to intents, though they can be manually annotated afterward if necessary.\u003c/p\u003e\n"],["\u003cp\u003eThe Dialogflow CX console or the \u003ccode\u003eEntityType\u003c/code\u003e API's \u003ccode\u003ecreate\u003c/code\u003e method can be used to create custom entities by providing entity data.\u003c/p\u003e\n"],["\u003cp\u003eCustom entities can be exported and imported in various formats, including JSON packages, which facilitates sharing across agents.\u003c/p\u003e\n"],["\u003cp\u003eWhen importing entities, merge conflicts can occur, and you can decide whether to replace, merge, rename, or skip existing entity types based on display name matches.\u003c/p\u003e\n"]]],[],null,["# Custom entities\n\nYou can create custom entities for matching data specific to your agent.\nFor example, you could define a `vegetable` entity type\nthat can match the types of vegetables\navailable for purchase with a grocery store agent.\n| **Note:** When building your agent, it's best to define your entities prior to adding [training phrases](/dialogflow/cx/docs/concept/intent#tp) to your intents. The console will automatically annotate your training phrases with existing entities. However, if you create entities after training phrases, you can manually annotate the phrases.\n\nCreate custom entities\n----------------------\n\nTo create a custom entity: \n\n### Console\n\n1. Open the [Dialogflow CX console](https://dialogflow.cloud.google.com/cx/projects).\n2. Choose your Google Cloud project.\n3. Select your agent.\n4. Select the **Manage** tab.\n5. Click **Entity Types**.\n6. Click **Create**.\n7. Enter entity data.\n8. Click **Save**.\n\n### API\n\nUse the `EntityType`'s `create` method.\n\n\nGo to the EntityType API reference \n**Select a protocol and version for the EntityType reference:**\n\nClose\n\n\u003cbr /\u003e\n\nLimitations\n-----------\n\nThe following limitations apply:\n\n- Custom entity type display names are unique for each agent. Entity type display names should start with a letter and can contain the following: `A-Z`, `a-z`, `0-9`, `_` (underscore), `-` (dash). Entity reference and synonym values have no such limitation.\n\nExport and import custom entities\n---------------------------------\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nYou can export and import entities for sharing across agents.\n\nOne of the export format options is Json package,\nwhich is a zip file that contains a hierarchy\nof directories and JSON files.\nThe following describes the directory structure:\n\n- `entityTypes`: This directory contains your entity types.\n - `\u003centity type name\u003e`: One or more of these directories exist, and the directory names correspond to entity type display names.\n - `entities`: This directory contains entity entry files.\n - `\u003clanguage tag\u003e.json`: One or more of these files exist, and the file names correspond to language tags. Each file contains language-specific entity entries.\n - `\u003cexcludedPhrases\u003e`: This directory contains [excluded phrase](/dialogflow/cx/docs/concept/entity-options#exclusion) files.\n - `\u003clanguage tag\u003e.json`: One or more of these files exist, and the file names correspond to language tags. Each file contains language-specific phrase exclusions.\n - `\u003centity type name\u003e.json`: This filename corresponds to an entity type display name. The file contains entity-type-specific data not found in other files.\n\nFor example: \n\n```\nfolder entityTypes\n ⤷ folder Entity Type A\n ⤷ folder entities\n ⤷ insert_drive_file en.json\n ⤷ insert_drive_file en-gb.json\n ⤷ insert_drive_file en-ca.json\n ⤷ folder excludedPhrases\n ⤷ insert_drive_file en.json\n ⤷ insert_drive_file en-gb.json\n ⤷ insert_drive_file en-ca.json\n ⤷ insert_drive_file Entity Type A.json\n ⤷ folder Entity Type B\n ⤷ folder entities\n ⤷ insert_drive_file en.json\n ⤷ insert_drive_file en-gb.json\n ⤷ insert_drive_file en-ca.json\n ⤷ folder excludedPhrases\n ⤷ insert_drive_file en.json\n ⤷ insert_drive_file en-gb.json\n ⤷ insert_drive_file en-ca.json\n ⤷ insert_drive_file Entity Type B.json\n```\n\nWhen importing entity types,\nthere may be merge conflicts when the display name of an\nentity type in your existing agent matches that of an imported entity type.\nYou can control the merge behavior when entity type display names match\nby selecting one of the following:\n\n- **Replace existing entity types**: An imported entity type overwrites any same-named entity type in your existing agent.\n- **Merge with existing entity types**: The entity entries of an imported entity type are added to the existing entity type. If the same entity entries exist, they won't be duplicated, and the synonyms under them will be merged.\n- **Rename and import as new entity types**: The imported entity type is renamed by appending \"_1\" to the display name.\n- **Skip the entity types**: The existing entity type remains unchanged, and the imported entity type is ignored.\n\nTo export entity types: \n\n### Console\n\n1. Open the [Dialogflow CX console](https://dialogflow.cloud.google.com/cx/projects).\n2. Choose your Google Cloud project.\n3. Select your agent.\n4. Select the **Manage** tab.\n5. Click **Entity Types**.\n6. Select all the entity types you want to export.\n7. Click **Export selected entity**.\n8. Select the format and destination.\n9. Click **Submit**.\n\nTo import entity types: \n\n### Console\n\n1. Open the [Dialogflow CX console](https://dialogflow.cloud.google.com/cx/projects).\n2. Choose your Google Cloud project.\n3. Select your agent.\n4. Select the **Manage** tab.\n5. Click **Entity Types**.\n6. Click **Import**.\n7. Select the source and merge behavior.\n8. Click **Submit**.\n\nImport entity entries\n---------------------\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nYou can import entity entries to an existing entity type.\n\nThe file format used for importing entity entries is the same as the format\nused for importing entity types. However, the import file can only contain 1\nentity type and all the entries under it will be imported to the selected entity\ntype.\nIf the same entity entries exist, they won't be duplicated,\nand the synonyms under them will be merged.\n\nTo import entity entries for an entity type: \n\n### Console\n\n1. Open the [Dialogflow CX console](https://dialogflow.cloud.google.com/cx/projects).\n2. Choose your Google Cloud project.\n3. Select your agent.\n4. Select the **Manage** tab.\n5. Click **Entity Types**.\n6. Select an entity.\n7. Click **Import to entity**.\n8. Select a file.\n9. Click **Submit**."]]