Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Ora che hai l'entità sequenza, puoi creare gli intent per raccogliere la sequenza dall'utente finale. Ti consigliamo di avere almeno tre intent con queste responsabilità:
Un'intenzione principale "Sequence"
Cattura le frasi per avviare la raccolta di sequenze.
Viene invocato dagli eventi di follow-up per continuare a acquisire sequenze finché l'utente finale non indica che ha terminato.
Un'intenzione contestuale "Sequenza - Modifica"
Cattura le frasi per correggere l'ultima sequenza raccolta.
Torna programmaticamente all'intent "Sequence" per raccogliere la sequenza corretta.
Un'intenzione contestuale "Sequence - Done"
Cattura le frasi che indicano che la sequenza è completa.
Nella sezione successiva vedrai come l'webhook collegherà tutti questi elementi, ma prima
configuriamo gli intent.
Crea l'intent "Sequenza"
Questo è lo scopo principale della raccolta delle sequenze. Configurala nel seguente modo:
Lascia vuoti i contesti di input in modo che gli utenti finali possano attivare questo intento all'inizio della chiamata.
Aggiungi un contesto di output "collecting-sequence". Utilizzeremo questo contesto per attivare le intenzioni di correzione e completamento durante il flusso.
Aggiungi un contesto di output "editing-sequence" e imposta la durata su 0. Attiveremo questo contesto con una durata dall'intent "Sequenza - Modifica" nella sezione successiva ed è importante cancellarlo qui in modo che il contesto "editing-sequence" sia attivo solo immediatamente dopo l'attivazione dell'intent "Modifica".
Aggiungi un evento "continue-sequence" in modo che l'webhook possa ripetere questo intento per raccogliere tutte le sequenze parziali.
Aggiungi frasi di addestramento in modo che l'utente finale possa attivare questa intenzione per avviare il flusso.
Questo esempio utilizza frasi come "qual è lo stato del mio ordine", "monitora il mio ordine", "dove si trova il mio ordine" e così via.
Aggiungi un nome di azione "handle-sequence" in modo che il webhook sappia quando attivarsi.
Codificherai l'webhook nella sezione successiva di questo tutorial, dopo aver configurato tutti gli scopi.
Aggiungi un parametro obbligatorio "new_sequence" utilizzando l'entità regexp che hai creato per raccogliere le sequenze parziali nella sezione precedente. Imposta il tipo di entità su "@alphanumeric" e il valore su "$new_sequence".
Aggiungi un parametro facoltativo "existing_sequence" con valore
"#continue-sequence.existing_sequence" per estrarre la nuova sequenza esistente
dall'evento. Puoi lasciare vuoto il tipo di entità.
Aggiungi un parametro facoltativo "previous_sequence" con valore
"#continue-sequence.previous_sequence" per estrarre la sequenza precedente
dall'evento. Puoi lasciare vuoto il tipo di entità.
Attiva la chiamata webhook per questo intent e la chiamata webhook per la compilazione degli slot.
Crea l'intent "Sequenza - Modifica"
Questo intento rileva le frasi che indicano che la sequenza precedente è stata interpretata erroneamente dall'agente. Configurala nel seguente modo:
Aggiungi un contesto di input "collecting-sequence" in modo che questo intento venga chiamato solo quando siamo nel mezzo del flusso di sequenza. Si tratta dello stesso contesto attivato dall'intento "Sequenza".
Aggiungi un contesto di output "editing-sequence" da fare riferimento al nostro webhook di adempimento. Quando questo intento viene attivato, il webhook fa tornare Dialogflow
all'intento principale "Sequenza" per raccogliere la sequenza successiva. Il webhook per il completamento degli slot dell'intent "Sequenza" verificherà la presenza di un contesto "editing-sequence" attivo per fornire una risposta di tipo "riprova" all'utente finale.
Aggiungi frasi di addestramento come "no", "non è corretto" e così via.
Aggiungi il nome dell'azione "handle-sequence". Si tratta della stessa azione dell'intenzione "Sequenza", quindi possiamo riutilizzare la stessa logica di webhook.
Aggiungi un parametro "new_sequence" con valore
"#collecting-sequence.previous_sequence" per estrarre la sequenza precedente
dal contesto, annullando di fatto l'ultimo enunciato. Non aggiungiamo un parametro "existing_sequence" qui in modo che l'webhook sovrascriva la sequenza esistente con quella precedente.
Attiva la chiamata webhook per questo intent.
Crea un'intenzione "Sequenza - Fine".
Aggiungi un contesto di input "collecting-sequence"
Aggiungi un contesto di output "collecting-sequence" e imposta la durata su 0 per cancellare il contesto. Se la rimuovi, gli intent "Modifica" e "Fine" non si attiveranno di nuovo ora che l'agente ha terminato di raccogliere la sequenza.
Aggiungi frasi di addestramento come "è tutto", "è fatta" e così via.
Aggiungi un parametro "sequence" con valore
"#collecting-sequence.existing_sequence" per estrarre la sequenza
finale dal contesto.
Attiva la chiamata webhook per questo intent.
Collega le intenzioni tramite webhook
Ora hai tutto ciò che ti serve per codificare la logica di questi intent. Nella sezione successiva, vedrai come codificare l'webhook in modo da utilizzare tutti questi contesti, azioni, parametri ed eventi per completare il flusso di convalida della sequenza.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThere are three key intents for collecting sequences: "Sequence" to start and continue, "Sequence - Edit" to correct the last entry, and "Sequence - Done" to finalize the sequence.\u003c/p\u003e\n"],["\u003cp\u003eThe "Sequence" intent uses output contexts "collecting-sequence" and "editing-sequence" to manage the flow, along with the "continue-sequence" event and training phrases to start and continue sequence collection.\u003c/p\u003e\n"],["\u003cp\u003eThe "Sequence - Edit" intent utilizes the "collecting-sequence" input context to activate only during sequence collection, along with an "editing-sequence" output context to inform the webhook to correct the sequence.\u003c/p\u003e\n"],["\u003cp\u003eThe "Sequence - Done" intent, triggered by phrases indicating sequence completion, clears the "collecting-sequence" context to prevent further edits and extracts the complete sequence.\u003c/p\u003e\n"],["\u003cp\u003eAll three intents use the same action name "handle-sequence" and webhook calls, which allows a single webhook to manage the sequence validation flow.\u003c/p\u003e\n"]]],[],null,["# Creating the sequence flow intents\n\nNow that you have your sequence entity, you can create the intents to collect the\nsequence from the end-user. You'll want at least three intents with these responsibilities:\n\n1. A head intent \"Sequence\"\n - Catches utterances to start the sequence collection.\n - Invoked by follow-up events to continue capturing sequences until the end-user says they're done.\n2. A contextual intent \"Sequence - Edit\"\n - Catches utterances to correct the last sequence collected.\n - Programmatically loops back to the \"Sequence\" intent to collect the corrected sequence.\n3. A contextual intent \"Sequence - Done\"\n - Catches utterances that indicate the sequence is complete.\n\nIn the next section, you'll see how webhook will connect all of these, but first\nlet's set up the intents.\n\nCreate the \"Sequence\" intent\n----------------------------\n\nThis is the main intent for collecting sequences. Configure it like so:\n\n1. Leave the input contexts empty so end-users can trigger this intent at the start of the call.\n2. Add an output context \"collecting-sequence\". We'll use this context to enable the correcting and finishing intents during the flow.\n3. Add an output context \"editing-sequence\" and set the lifespan to 0. We'll activate this context with a lifespan from the \"Sequence - Edit\" intent in the next section, and it's important to clear that context here so that the \"editing-sequence\" context is only active immediately after triggering the \"Edit\" intent.\n4. Add an event \"continue-sequence\" so your webhook can loop this intent to\n collect all of the partial sequences.\n\n5. Add training phrases so the end-user can trigger this intent to start the flow.\n This example uses phrases like \"what's my order status\", \"track my order\",\n \"where is my order\", etc.\n\n6. Add an action name \"handle-sequence\" so the webhook knows when to fire.\n You'll code the webhook in the next section of this tutorial, after all the\n intents are set up.\n\n7. Add a required parameter \"new_sequence\" using the regexp entity you created\n to collect partial sequences in the previous section. Set the entity type to\n \"@alphanumeric\" and the value to \"$new_sequence\".\n\n8. Add an optional parameter \"existing_sequence\" with value\n \"#continue-sequence.existing_sequence\" to extract the new existing sequence\n from the event. You can leave the entity type empty.\n\n9. Add an optional parameter \"previous_sequence\" with value\n \"#continue-sequence.previous_sequence\" to extract the previous sequence\n from the event. You can leave the entity type empty.\n\n10. Enable webhook call for this intent *and* webhook call for slot filling.\n\nCreate the \"Sequence - Edit\" intent\n-----------------------------------\n\nThis intent listens for utterances that indicate the previous sequence was\nmisheard by the agent. Set it up like this:\n\n1. Add an input context \"collecting-sequence\" so that this intent is only called when we're in the middle of the sequence flow. This is the same context activated by the \"Sequence\" intent.\n2. Add an output context \"editing-sequence\" for our fulfillment webhook to reference. When this intent is activated, the webhook will loop Dialogflow back to the main \"Sequence\" intent to collect the next sequence. The webhook for the \"Sequence\" intent's slot-filling will check for an active \"editing-sequence\" context to provide a sympathetic \"try again\" response to the end-user.\n3. Add training phrases like \"no\", \"that's not right\", etc.\n\n4. Add the action name \"handle-sequence\". This is the same action as the\n \"Sequence\" intent so we can reuse the same webhook logic.\n\n5. Add a parameter \"new_sequence\" with value\n \"#collecting-sequence.previous_sequence\" to extract the previous sequence\n from the context, effcetively undoing the last utterance. We do *not* add an\n \"existing_sequence\" parameter here so that the webhook will overwrite the\n existing sequence with the previous one.\n\n6. Enable webhook call for this intent.\n\nCreate a \"Sequence - Done\" intent.\n----------------------------------\n\n1. Add an input context \"collecting-sequence\"\n2. Add an output context \"collecting-sequence\" and set the lifespan to 0 to clear the context. Clearing it prevents the \"Edit\" and \"Done\" intents from triggering again now that the agent is done collecting the sequence.\n3. Add training phrases like \"that's it\", \"all done\", etc.\n\n4. Add a parameter \"sequence\" with value\n \"#collecting-sequence.existing_sequence\" to extract the final\n sequence from the context.\n\n5. Enable webhook call for this intent.\n\nLink the intents through webhook\n================================\n\nYou now have everything you need to code the logic for these intents. In the next\nsection, you'll see how to code the webhook to use all these contexts, actions,\nparameters, and events to complete the sequence validation flow."]]