[[["易于理解","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\u003eOutput contexts become active when their associated intent is matched, influencing the flow of the conversation.\u003c/p\u003e\n"],["\u003cp\u003eInput contexts control intent matching by making Dialogflow more likely to match intents with input contexts that are a subset of currently active contexts.\u003c/p\u003e\n"],["\u003cp\u003eContexts allow for controlling the order of intent matching and creating context-specific intents that use identical training phrases.\u003c/p\u003e\n"],["\u003cp\u003eActive contexts have a lifespan that determines how many conversational turns they remain active, with a default of five turns, and they expire after 20 minutes.\u003c/p\u003e\n"],["\u003cp\u003eWhen an intent with an output context is matched, its parameter values can be stored temporarily and accessed in future turns as long as the context remains active.\u003c/p\u003e\n"]]],[],null,["# Input and output contexts are applied to\n[intents](/dialogflow/docs/intents-overview).\nThey work together to control conversation flow:\n\n- [**Output contexts**](#output_contexts) control *active* contexts. When an intent is matched, any configured output contexts for that intent become active.\n- [**Input contexts**](#input_contexts) control intent matching. While contexts are active, Dialogflow is more likely to match intents that are configured with input contexts that are a subset of currently active contexts.\n\nWith contexts, you can:\n\n- Control the order of intent matching.\n- Create context-specific intents with the same training phrases.\n\nFor example, consider the following intents:\n\nWhen the end-user says `I like dogs`:\n\n- The `pet-select-dogs` intent is matched.\n- The output context is `dogs`, so it becomes the active context.\n\nWhen the end-user says `I like cats`:\n\n- The `pet-select-cats` intent is matched.\n- The output context is `cats`, so it becomes the active context.\n\nWhen the end-user says `What do they look like?`:\n\n- If `dogs` is the active context:\n - The `dog-show` intent is matched.\n - The end-user is shown a dog picture.\n- If `cats` is the active context:\n - The `cat-show` intent is matched.\n - The end-user is shown a cat picture.\n- If there is no active context:\n - The `pet-init` intent is matched.\n - The end-user is asked what kind of pet they like.\n\nOutput contexts\n---------------\n\nMultiple output contexts can be applied to an intent.\nWhen an intent is matched,\nany output contexts applied to the intent become active.\n\n### Parameter references for active contexts\n\nWhen an intent with output context is matched,\nits collected parameter values can serve as temporary storage with\n[parameter references for active contexts](/dialogflow/docs/intents-actions-parameters#context).\nThese values can be accessed during future intent matching,\nfor as long as the context remains active.\n\nFor example, consider the following variation of the pet example above:\n\nWhen the end-user says `I like dogs` or `I like cats`:\n\n- The `pet-select` intent is matched.\n- The `pet` [parameter](/dialogflow/docs/intents-actions-parameters) is set to the chosen pet type.\n- The output context is `pet-chosen`, so it becomes the active context.\n\nWhen the end-user says `What do they look like?`:\n\n- If `pet-chosen` is the active context:\n - The `pet-show` intent is matched.\n - If the end-user selected `dogs` in the prior conversational turn, the end-user is shown a dog picture.\n - If the end-user selected `cats` in the prior conversational turn, the end-user is shown a cat picture.\n- If there is no active context:\n - The `pet-init` intent is matched.\n - The end-user is asked to select a pet type.\n\n### Lifespan\n\nEach active context has a lifespan\nthat defines the number of conversational turns\nfor which the context remains active.\nThe default lifespan is five conversational turns for normal intents\nand two conversational turns for\n[follow-up intents](/dialogflow/docs/contexts-follow-up-intents).\nYou can override the default lifespan for any contexts.\nIn addition, all contexts expire after 20 minutes of becoming active.\nWhen an intent is matched with an output context that is already active,\nthe lifespan and expiration timer are reset.\n\nFor example, consider the following intent descriptions for a pet information agent:\n\nThe following table shows an example dialogue for this pet information agent,\nwhich illustrates the lifespan of the `pet-chosen`context:\n\nInput contexts\n--------------\n\nWhile contexts are active,\nDialogflow is more likely to match intents that are configured\nwith input contexts that correspond to the currently active contexts.\nThe detailed intent matching rules are as follows:\n\n1. An intent's input context list must be a subset of the currently active context list in order to be matched. This also applies to intents with no input contexts.\n2. For intents that satisfy rule #1, those with an input context list that most closely match the currently active context list are more likely to be matched.\n\nFor example:\n\n- Intents with no input contexts can be matched at any time.\n- When no contexts are active, only intents with no input contexts can be matched.\n- If contexts \"A\" and \"B\" are active, an intent with \"A\" and \"C\" input contexts cannot be matched.\n- If contexts \"A\", \"B\", and \"C\" are active, an intent with \"A\" and \"B\" input contexts can be matched.\n- If contexts \"A\" and \"B\" are active, an intent with \"A\" and \"B\" input contexts is more likely to be matched than an intent with no input context or an intent with just \"A\" for an input context."]]