const{sessionEntitiesHelper}=require('actions-on-google-dialogflow-session-entities-plugin')constapp=dialogflow().use(sessionEntitiesHelper())app.intent('input.welcome',(conv)=>{conv.ask('make your choice: apple or orange?');//Setthefruitsessionentityvaluesto'apple'and'orange'.conv.sessionEntities.add({name:'fruit',entities:[{value:'APPLE_KEY',synonyms:['apple','green apple','crabapple']},{value:'ORANGE_KEY',synonyms:['orange']}]});conv.sessionEntities.send();});
[[["易于理解","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\u003eSession entities are specialized entities created during a Dialogflow session that can extend or replace existing custom entity types.\u003c/p\u003e\n"],["\u003cp\u003eThese session entities exist only for the duration of the session in which they were created, with all session data stored by Dialogflow for 20 minutes.\u003c/p\u003e\n"],["\u003cp\u003eSession entities can be created using fulfillment, through the \u003ccode\u003eWebhookResponse\u003c/code\u003e type's \u003ccode\u003esessionEntityTypes\u003c/code\u003e field.\u003c/p\u003e\n"],["\u003cp\u003eThe Actions on Google client library includes a Session Entities plugin to simplify the process of creating and managing session entities within your code.\u003c/p\u003e\n"],["\u003cp\u003eSession entities can be created, updated, and managed using the \u003ccode\u003eSessionEntityTypes\u003c/code\u003e, however this method does not work with Google Assistant integration, requiring the fulfillment option.\u003c/p\u003e\n"]]],[],null,["# Session entities\n\nA *session* represents a conversation between a Dialogflow agent and an end-user.\nYou can create special entities, called *session entities*, during a session.\nSession entities can extend or replace custom entity types\nand only exist during the session that they were created for.\nAll session data, including session entities, is stored by Dialogflow for 20 minutes.\n\nFor example, if your agent has a `@fruit` entity type\nthat includes \"pear\" and \"grape\",\nthat entity type could be updated to include \"apple\" or \"orange\",\ndepending on the information your agent collects from the end-user.\nThe updated entity type would have the \"apple\" or \"orange\" entity entry\nfor the rest of the session.\n\nCreating session entities with fulfillment\n------------------------------------------\n\nYou can create session entities with\n[fulfillment](/dialogflow/docs/fulfillment-overview).\nThe\n[`WebhookResponse`](/dialogflow/docs/reference/common-types#webhookresponse)\ntype contains a field called `sessionEntityTypes`\nthat is used to set session entities.\n\nThe following examples show how to set a `fruit` entity type's\nentity entries to `apple` and `orange` for the current session.\n\n### Example WebhookResponse:\n\n```\n{\n \"fulfillmentMessages\": [\n {\n \"text\": {\n \"text\": [\n \"Choose apple or orange\"\n ]\n }\n }\n ],\n \"sessionEntityTypes\":[\n {\n \"name\":\"projects/project-id/agent/sessions/session-id/entityTypes/fruit\",\n \"entities\":[\n {\n \"value\":\"APPLE_KEY\",\n \"synonyms\":[\n \"apple\",\n \"green apple\",\n \"crabapple\"\n ]\n },\n {\n \"value\":\"ORANGE_KEY\",\n \"synonyms\":[\n \"orange\"\n ]\n }\n ],\n \"entityOverrideMode\":\"ENTITY_OVERRIDE_MODE_OVERRIDE\"\n }\n ]\n}\n```\n\n### Example using the Actions on Google client library:\n\nIf you are using the\n[Actions on Google client library](https://github.com/actions-on-google/actions-on-google-nodejs),\nyou can use the [Session Entities plugin](https://github.com/actions-on-google/dialogflow-session-entities-plugin-nodejs).\n\nYour code would look similar to the following: \n\n```gdscript\nconst { sessionEntitiesHelper } = require('actions-on-google-dialogflow-session-entities-plugin')\n\nconst app = dialogflow()\n .use(sessionEntitiesHelper())\n\napp.intent('input.welcome', (conv) =\u003e {\n conv.ask('make your choice: apple or orange?');\n // Set the fruit session entity values to 'apple' and 'orange'.\n conv.sessionEntities.add({\n name: 'fruit',\n entities: [{\n value: 'APPLE_KEY',\n synonyms: [\n 'apple', 'green apple', 'crabapple'\n ]\n }, {\n value: 'ORANGE_KEY',\n synonyms: ['orange']\n }]\n });\n conv.sessionEntities.send();\n});\n```\n\nCreating session entities with the API\n--------------------------------------\n\n| **Note:** Session entity API methods do not work with Google Assistant integration. Use the fulfillment option for Google Assistant integration.\n\nYou create, manage, and update session entities using the\n[`SessionEntityTypes`](/dialogflow/docs/reference/common-types#sessionentitytypes)\ntype."]]