이제 시퀀스 항목이 생성되었으므로 인텐트를 만들어 최종 사용자로부터 시퀀스를 수집하기 위한 인텐트를 만들 수 있습니다. 이러한 책임이 포함된 인텐트는 최소한 3개 이상 만들어야 합니다.
헤드 인텐트 '시퀀스'
시퀀스 수집을 시작할 발화를 캡처합니다.
최종 사용자가 끝났다고 말 할 때까지 캡처 시퀀스를 계속하기 위해 후속 이벤트에 의해 호출됩니다.
상황별 인텐트 '시퀀스 - 수정'
발화를 캡처하여 마지막으로 수집된 시퀀스를 수정합니다.
프로그래매틱 방식으로 '시퀀스' 인테트로 루프백하여 수정된 시퀀스를 수집합니다.
상황별 인텐트 '시퀀스 - 완료'
시퀀스가 완료되었음을 나타내는 발화를 캡처합니다.
다음 섹션에서는 웹훅이 이 모든 인텐트를 연결하는 방법을 확인하지만, 먼저 인텐트 설정을 수행합니다.
'시퀀스' 인텐트 만들기
시퀀스 수집을 위한 기본 인텐트입니다. 다음과 같이 구성합니다.
최종 사용자가 호출을 시작할 때 이 인텐트를 트리거할 수 있도록 입력 컨텍스트를 비워둡니다.
'collect-sequence' 출력 컨텍스트를 추가합니다. 이 컨텍스트는 흐름 중 인텐트 수정 및 완료를 사용 설정하기 위해 사용됩니다.
'editing-sequence' 출력 컨텍스트를 추가하고 수명을 0으로 설정합니다. 다음 섹션에서는 '시퀀스 수정' 인텐트에서 수명을 지정하여 이 컨텍스트를 활성화합니다. 'editing-sequence' 컨텍스트가 '수정' 인텐트를 트리거한 직후에만 활성 상태가 되도록 컨텍스트를 지우는 것이 중요합니다.
웹훅이 모든 부분 시퀀스 수집을 위해 이 인텐트를 반복할 수 있도록 'continue-sequence' 이벤트를 추가합니다.
최종 사용자가 흐름을 시작하기 위해 이 인텐트를 트리거할 수 있도록 학습 문구를 추가합니다.
이 예시에서는 '내 주문 상태 알려줘', '내 주문 추적', '내 주문 상태'와 같은 문구를 사용합니다.
웹훅이 실행할 지점을 알 수 있도록 'handle-sequence' 작업 이름을 추가합니다.
모든 인텐트가 설정된 후 이 가이드의 다음 섹션에서 웹훅 코드를 작성합니다.
이전 섹션에서 부분 시퀀스를 수집하기 위해 만든 정규 표현식 항목을 사용하여 필수 매개변수 'new_sequence'를 추가합니다. 항목 유형을 '@alphanumeric'으로 설정하고 값을 '$new_sequence'로 설정합니다.
이벤트에서 기존 시퀀스를 새로 추출하기 위해 '#continue-sequence.existing_sequence' 값을 사용하여 선택적 매개변수 'existing_sequence'를 추가합니다. 항목 유형은 비워 둘 수 있습니다.
이벤트에서 이전 시퀀스를 추출하기 위해 '#continue-sequence.previous_sequence' 값을 사용하여 선택적 매개변수 'previous_sequence'를 추가합니다. 항목 유형은 비워 둘 수 있습니다.
이 인텐트 및 슬롯 채우기를 위해 웹훅 호출을 사용 설정합니다.
'시퀀스 수정' 인텐트 만들기
이 인텐트는 에이전트가 이전 시퀀스를 잘못 들었음을 나타내는 발화를 리슨합니다. 다음과 같이 설정합니다.
시퀀스 흐름의 중간에 있을 때만 이 인텐트가 호출되도록 'collecting-sequence' 입력 컨텍스트를 추가합니다. 이것은 '시퀀스' 인텐트로 활성화되는 것과 동일한 컨텍스트입니다.
처리 웹훅이 참조할 'editing-sequence' 출력 컨텍스트를 추가합니다. 이 인텐트가 활성화되면 웹훅이 다음 시퀀스를 수집하기 위해 Dialogflow를 기본 '시퀀스' 인텐트로 루프백합니다. '시퀀스' 인텐트의 슬롯 채우기를 위한 웹훅은 활성 'editing-sequence' 컨텍스트를 확인하여 최종 사용자에게 안타깝지만 '다시 시도하세요' 응답을 제공합니다.
'아니요', '맞지 않습니다'와 같은 학습 문구를 추가합니다.
'handle-sequence' 작업 이름을 추가합니다. 이것은 동일한 웹훅 논리를 재사용할 수 있도록 '시퀀스' 인텐트와 동일한 작업입니다.
컨텍스트에서 이전 시퀀스를 추출하여 마지막 발화를 효과적으로 실행 취소하기 위해 '#collecting-sequence.previous_sequence' 값을 사용하여 'new_sequence' 매개변수를 추가합니다. 웹훅이 기존 시퀀스를 이전 시퀀스로 덮어쓰도록 'existing_sequence' 매개변수를 추가하지 않습니다.
이 인텐트에 대해 웹훅 호출을 사용 설정합니다.
'시퀀스 - 완료' 인텐트를 만듭니다.
'collecting-sequence' 입력 컨텍스트를 추가합니다.
'collecting-sequence' 출력 컨텍스트를 추가하고 수명을 0으로 설정하여 컨텍스트를 지웁니다. 이를 지우면 '수정' 및 '완료' 인텐트가 다시 트리거되지 않으므로 에이전트가 시퀀스 수집을 완료합니다.
'맞아', '모두 완료' 등과 같은 학습 문구를 추가합니다.
컨텍스트에서 최종 시퀀스를 추출하기 위해 '#collecting-sequence.existing_sequence' 값을 사용하여 'sequence' 매개변수를 추가합니다.
이 인텐트에 대해 웹훅 호출을 사용 설정합니다.
웹훅을 통해 인텐트 연결
이제 모든 것이 준비되었으므로 이러한 인텐트에 대한 논리를 코드로 작성해야 합니다. 다음 섹션에서는 이러한 모든 컨텍스트, 작업, 매개변수, 이벤트를 사용하여 시퀀스 검증 흐름을 완료하도록 웹훅 코드를 작성하는 방법을 살펴봅니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-03-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."]]