Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Les contextes Dialogflow s'apparentent à la notion de contexte en langage naturel.
Si un interlocuteur vous dit "ils sont orange", vous avez besoin de contexte pour comprendre à quoi "ils" fait référence.
De même, pour traiter une expression d'utilisateur final de ce type, Dialogflow a besoin de recevoir avec cette expression un contexte permettant la mise en correspondance d'un intent.
L'utilisation de contextes vous permet de contrôler le flux d'une conversation.
Vous pouvez configurer des contextes pour un intent en définissant des contextes d'entrée et de sortie, qui sont identifiés par des noms de type chaîne.
Lorsqu'un intent est mis en correspondance, les éventuels contextes de sortie associés à cet intent sont activés.
Lorsque les contextes sont actifs, Dialogflow est plus susceptible de mettre en correspondance les intents configurés avec des contextes d'entrée qui correspondent aux contextes actuellement actifs.
L'exemple illustré dans le schéma suivant fait intervenir un contexte pour un agent bancaire.
L'utilisateur final demande des informations sur son compte courant.
Dialogflow met cette expression de l'utilisateur final en correspondance avec l'intent CheckingInfo.
Cet intent possède un contexte de sortie checking, qui devient par conséquent actif.
L'agent demande à l'utilisateur final quel type d'informations il souhaite obtenir concernant son compte bancaire.
L'utilisateur final répond : "mon solde".
Dialogflow met cette expression de l'utilisateur final en correspondance avec l'intent CheckingBalance.
Cet intent a un contexte d'entrée checking, qui doit être actif pour que l'intent soit mis en correspondance.
Il se peut que l'intent voisin SavingsBalance soit également défini, de façon à permettre la mise en correspondance de la même expression d'utilisateur final lorsqu'un contexte savings est actif.
Une fois que votre système a effectué les requêtes de base de données requises, l'agent répond en annonçant le solde du compte courant.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eDialogflow's contexts are used to understand user expressions by providing necessary conversational context, similar to how humans understand natural language.\u003c/p\u003e\n"],["\u003cp\u003eContexts control conversation flow by setting input and output contexts for intents, identified by string names.\u003c/p\u003e\n"],["\u003cp\u003eWhen an intent is matched, its output contexts become active, influencing which intents are more likely to be matched next.\u003c/p\u003e\n"],["\u003cp\u003eDialogflow matches intents with specific input contexts only when those contexts are currently active, allowing for tailored responses.\u003c/p\u003e\n"],["\u003cp\u003eThe banking agent example shows how the "checking" output context from the \u003ccode\u003eCheckingInfo\u003c/code\u003e intent enables the \u003ccode\u003eCheckingBalance\u003c/code\u003e intent to be matched later when a user asks for their balance.\u003c/p\u003e\n"]]],[],null,["# Contexts\n\nDialogflow\n\n*contexts*\n\nare similar to natural language context.\nIf a person says to you \"they are orange\",\nyou need context in order to understand what \"they\" is referring to.\nSimilarly, for Dialogflow to handle an end-user expression like that,\nit needs to be provided with context in order to correctly match an intent.\n\n\nUsing contexts,\nyou can control the flow of a conversation.\nYou can configure contexts for an intent by setting\n[input and output contexts](/dialogflow/docs/contexts-input-output),\nwhich are identified by string names.\nWhen an intent is matched,\nany configured *output contexts* for that intent become active.\nWhile any contexts are active,\nDialogflow is more likely to match intents\nthat are configured with *input contexts* that correspond to\nthe currently active contexts.\n\n\nThe following diagram shows an example that uses context for a banking agent.\n\n1. The end-user asks for information about their checking account.\n2. Dialogflow matches this end-user expression to the `CheckingInfo` intent. This intent has a `checking` output context, so that context becomes active.\n3. The agent asks the end-user for the type of information they want about their checking account.\n4. The end-user responds with \"my balance\".\n5. Dialogflow matches this end-user expression to the `CheckingBalance` intent. This intent has a `checking` input context, which needs to be active to match this intent. A similar `SavingsBalance` intent may also exist for matching the same end-user expression when a `savings` context is active.\n6. After your system performs the necessary database queries, the agent responds with the checking account balance."]]