ParseDialogflowRequest 정책

이 페이지는 ApigeeApigee Hybrid에 적용됩니다.

Apigee Edge 문서 보기

정책 아이콘

개요

ParseDialogflowRequest 정책은 Dialogflow와 Apigee의 통합을 도와줍니다. 자세한 내용은 Apigee와 Contact Center AI 통합을 참조하세요.

이 정책은 확장 가능한 정책이며, 이 정책을 사용하면 Apigee 라이선스에 따라 비용 또는 사용률이 영향을 받을 수 있습니다. 정책 유형 및 사용 영향에 대한 자세한 내용은 정책 유형을 참조하세요.

ParseDialogflowRequest 정책은 요청 데이터를 백엔드 시스템에 보내기 전에 Dialogflow 에이전트에서 WebhookRequest를 처리합니다. 정책은 WebhookRequest에서 전체 API 호출 기간 동안 사용 가능한 흐름 변수로 데이터를 추출합니다. 후속 콜아웃, 조회 또는 조정된 로직에서 변수를 사용할 수 있습니다. 이 정책은 Dialogflow 에이전트가 기존 백엔드 시스템과 상호작용하도록 하려는 경우에 특히 유용합니다. 에이전트의 데이터를 백엔드 시스템에 보내기 전에 백엔드 시스템이 사용할 수 있는 방식으로 데이터를 파싱하고 구조화할 수 있습니다.

백엔드 서비스 통합업체는 Dialogflow WebhookRequest의 형식을 이해하는 데 시간을 소비할 필요가 없습니다. 즉시 사용 가능한 ParseDialogflowRequest 정책이 요청 데이터를 원활하게 처리해 줍니다.

Apigee에서 Dialogflow 에이전트의 WebhookRequest에 액세스하려면 에이전트의 웹훅 URL(fulfillment)을 Apigee에서 구성한 ProxyEndPoint로 설정해야 합니다. ProxyEndPoint에 공개적으로 액세스할 수 있어야 합니다. 자세한 내용은 웹훅 서비스 요구사항을 참조하세요.

<ParseDialogflowRequest>

ParseDialogflowRequest 정책을 정의합니다.

기본값 해당 사항 없음
필수 여부 필수
유형 복합 객체
상위 요소 해당 사항 없음
하위 요소 <DialogflowVersion>
<DisplayName>
<VariablePrefix>

다음 표에서는 ParseDialogflowRequest 정책과 관련된 하위 요소를 간략하게 설명합니다.

하위 요소 필수 여부 설명
<VariablePrefix> 선택사항 흐름 변수의 커스텀 프리픽스를 지정합니다.
<DialogflowVersion> 선택사항 Dialogflow 버전을 지정합니다.

다음 예시에서는 샘플 웹훅 요청, 해당 ParseDialogflowRequest 정책, 정책을 적용한 후 생성된 흐름 변수를 보여줍니다.

구문

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ParseDialogflowRequest continueOnError="false" enabled="true"
        name="POLICY_NAME">
    <!-- The display name for this policy -->
    <DisplayName>DISPLAY_NAME</DisplayName>
    <!-- The optional prefix to be added to all variables created from the
         Dialogflow Webhook request. Note that all variables created from the
         WebhookRequest object will be within a container named
         "google.dialogflow" -->
    <VariablePrefix>CUSTOM_PREFIX</VariablePrefix>
    <!-- The version of Dialogflow for which this request policy is written up.
         This policy supports only the CX version. This element is optional and
         defaults to CX if unspecified -->
    <DialogflowVersion>DIALOGFLOW_VERSION</DialogflowVersion>
</ParseDialogflowRequest>

웹훅 요청

다음 예시에서는 Dialogflow 에이전트의 웹훅 요청(JSON 형식)을 보여줍니다.

{
    "fulfillmentInfo": {
        "tag": "check-claim-status"
    },
    "sessionInfo": {
        "session": "projects/apigee-test/locations/global/agents/ea45003d-3f5c-46ba-ac6b-f4c6dc8db707/sessions/5ea2e8-7c1-cf4-2cf-8e4d89e72",
        "parameters": {
            "claimId": "1234",
            "policyId": "abcd"
        }
    },
    "sentimentAnalysisResult": {
      "score": -0.7,
      "magnitude": 0.7
  }
}

요청에서 구성할 수 있는 다양한 필드는 WebhookRequest를 참조하세요.

다음 샘플로 이동하여 ParseDialogflowRequest 정책 구성을 확인합니다.

ParseDialogflowRequest 정책

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ParseDialogflowRequest continueOnError="false" enabled="true"
        name="DialogflowRequest-InsuranceAgent">
    <DisplayName>Insurance Agent Webhook Request Policy</DisplayName>
    <VariablePrefix>my-prefix</VariablePrefix>
    <DialogflowVersion>CX</DialogflowVersion>
</ParseDialogflowRequest>

다음 샘플로 이동하여 정책에서 만든 흐름 변수를 확인합니다.

흐름 변수

google.dialogflow.my-prefix.fulfillment.tag = "check-claim-status"
google.dialogflow.my-prefix.session.id = "5ea2e8-7c1-cf4-2cf-8e4d89e72"
google.dialogflow.my-prefix.session.project.id = "apigee-test"
google.dialogflow.my-prefix.session.agent.id = "ea45003d-3f5c-46ba-ac6b-f4c6dc8db707"
google.dialogflow.my-prefix.session.parameters.claimId = "1234"
google.dialogflow.my-prefix.session.parameters.policyId = "abcd"
google.dialogflow.my-prefix.sentimentAnalysisResultScore = -0.7
google.dialogflow.my-prefix.sentimentAnalysisResultMagnitude = 0.7

생성된 모든 흐름 변수는 google.dialogflow로 시작하고 <VariablePrefix> 요소에 지정된 프리픽스(my-prefix)로 이어집니다.

이 요소에는 다음과 같이 모든 정책에 공통된 속성이 있습니다.

속성 기본값 필수 여부 설명
name 해당 사항 없음 필수

정책의 내부 이름입니다. name 속성의 값에는 문자, 숫자, 공백, 하이픈, 밑줄, 마침표가 포함될 수 있습니다. 이 값은 255자(영문 기준)를 초과할 수 없습니다.

원하는 경우 <DisplayName> 요소를 사용하여 관리 UI 프록시 편집기의 정책에 다른 자연어 이름을 사용하여 정책에 라벨을 지정합니다.

continueOnError 거짓 선택사항 정책이 실패할 경우 오류가 반환되도록 하려면 false로 설정합니다. 이는 대부분의 정책에서 예상되는 동작입니다. 정책이 실패해도 흐름 실행이 계속되도록 하려면 true로 설정합니다. 참조:
enabled 선택사항 정책을 시행하려면 true로 설정합니다. 정책을 중지하려면 false로 설정합니다. 정책이 흐름에 연결되어 있어도 정책이 시행되지 않습니다.
async   거짓 지원 중단됨 이 속성은 지원이 중단되었습니다.

하위 요소 참조

이 섹션에서는 <ParseDialogflowRequest>의 하위 요소를 설명합니다.

<DisplayName>

name 속성 외에 이 요소를 사용하여 관리 UI 프록시 편집기에서 자연스러운 다른 이름으로 정책의 라벨을 지정합니다.

<DisplayName> 요소는 모든 정책에 공통으로 적용됩니다.

기본값 해당 사항 없음
필수 여부 선택사항. <DisplayName>을 생략하면 정책의 name 속성 값이 사용됩니다.
유형 문자열
상위 요소 <PolicyElement>
하위 요소 없음

<DisplayName> 요소는 다음 문법을 사용합니다.

구문

<PolicyElement>
  <DisplayName>POLICY_DISPLAY_NAME</DisplayName>
  ...
</PolicyElement>

<PolicyElement>
  <DisplayName>My Validation Policy</DisplayName>
</PolicyElement>

<DisplayName> 요소에 속성 또는 하위 요소가 없습니다.

<VariablePrefix>

흐름 변수의 커스텀 프리픽스를 지정합니다. 이 요소에 지정된 값은 ParseDialogflowRequest 정책으로 생성된 모든 변수 이름에 프리픽스로 추가됩니다. 기본적으로 정책에 의해 생성된 모든 변수에는 google.dialogflow 프리픽스가 추가됩니다. VariablePrefix 요소를 지정한 경우 커스텀 프리픽스가 google.dialogflow 뒤에 추가됩니다. 따라서 변수 이름은 google.dialogflow.CUSTOM_PREFIX로 시작합니다.

VariablePrefix 요소를 지정하지 않으면 변수 이름에 google.dialogflow로만 프리픽스가 추가됩니다.

기본값 해당 사항 없음
필수 여부 선택사항
유형 문자열
상위 요소 <ParseDialogflowRequest>
하위 요소 없음
<VariablePrefix> 요소는 다음 문법을 사용합니다.

구문

<VariablePrefix>VARIABLE_PREFIX</VariablePrefix>

다음 예시에서는 VariablePrefix를 my-prefix로 설정합니다.

<VariablePrefix>my-custom-prefix</VariablePrefix>

이 구성에 따라 모든 변수 이름이 google.dialogflow.my-custom-prefix로 시작됩니다.

<DialogflowVersion>

Dialogflow 버전을 지정합니다. ParseDialogflowRequest 정책은 CX 버전만 지원합니다. 정책에서 이 요소를 지정하지 않으면 버전은 기본적으로 CX가 됩니다.

기본값 해당 사항 없음
필수 여부 선택사항
유형 문자열
상위 요소 해당 사항 없음
하위 요소 없음
<DialogflowVersion> 요소는 다음 문법을 사용합니다.

구문

<DialogflowVersion>DIALOGFLOW_VERSION</DialogflowVersion>

다음 예시에서는 DialogflowVersion을 CX로 설정합니다.

<DialogflowVersion>CX</DialogflowVersion>

오류 코드

This section describes the fault codes and error messages that are returned and fault variables that are set by Apigee when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors and Handling faults.

Runtime errors

These errors can occur when the policy executes.

Fault code HTTP status Cause Fix
steps.parsedialogflowrequest.InvalidSessionInfo 500 This error occurs if there is an invalid sessionInfo.session field in a Dialogflow request. A Webhook can use this field to identify a session. For information about the supported session format, see Class SessionInfo.
steps.parsedialogflowrequest.MalformedInput 500 This error occurs when the JSON provided to this policy is invalid or malformed.

Deployment errors

These errors can occur when you deploy a proxy containing this policy.

Error name Cause Fix
UnsupportedOperation This error occurs if you have specified unsupported Dialogflow version in the DialogflowVersion element. The ParseDialogflowRequest policy supports only CX version.

Fault variables

Whenever there are execution errors in a policy, Apigee generates error messages. You can view these error messages in the error response. Many a time, system generated error messages might not be relevant in the context of your product. You might want to customize the error messages based on the type of error to make the messages more meaningful.

To customize the error messages, you can use either fault rules or the RaiseFault policy. For information about differences between fault rules and the RaiseFault policy, see FaultRules vs. the RaiseFault policy. You must check for conditions using the Condition element in both the fault rules and the RaiseFault policy. Apigee provides fault variables unique to each policy and the values of the fault variables are set when a policy triggers runtime errors. By using these variables, you can check for specific error conditions and take appropriate actions. For more information about checking error conditions, see Building conditions.

The following table describes the fault variables specific to this policy.

Variables Where Example
fault.name="FAULT_NAME" FAULT_NAME is the name of the fault, as listed in the Runtime errors table. The fault name is the last part of the fault code. fault.name Matches "UnresolvedVariable"
ParseDialogflowRequest.POLICY_NAME.failed POLICY_NAME is the user-specified name of the policy that threw the fault. ParseDialogflowRequest.My-Parse-Dialogflow-Req.failed = true
For more information about policy errors, see What you need to know about policy errors.

관련 주제

ParseDialogflowRequest 정책 사용을 보여주는 Apigee 프록시 및 공유 흐름의 참조 구현은 Apigee GitHub에서 확인할 수 있습니다. 자세한 내용은 대화형 AI 참조 구현을 참조하세요.