מדיניות ParseDialogflowRequest

מדיניות ניתנת להרחבה

הדף הזה רלוונטי ל-Apigee ול-Apigee Hybrid.

לעיון במסמכי התיעוד של Apigee Edge

המדיניות ParseDialogflowRequest מאפשרת לשלב את Dialogflow עם Apigee. מידע נוסף זמין במאמר שילוב של Apigee עם Contact Center AI.

המדיניות הזו היא מדיניות שניתנת להרחבה, והשימוש בה עשוי להשפיע על העלויות או על הניצול, בהתאם לרישיון שלכם ל-Apigee. למידע על סוגי מדיניות והשלכות השימוש, אפשר לעיין במאמר בנושא סוגי מדיניות.

המדיניות ParseDialogflowRequest מעבדת את WebhookRequest מסוכן Dialogflow לפני שליחת נתוני הבקשה למערכות העורפיות שלכם. המדיניות מחלצת נתונים מ-WebhookRequest לתוך משתני התהליך שזמינים לכם למשך כל הקריאה ל-API. אפשר להשתמש במשתנים ב-callout, בחיפושים או בלוגיקה המאורגנת הבאים. המדיניות הזו שימושית במיוחד אם רוצים שהסוכן של Dialogflow יקיים אינטראקציה עם מערכות קצה עורפיות מדור קודם. לפני ששולחים את הנתונים של הסוכן למערכות העורפיות, אפשר לנתח את הנתונים ולבנות אותם בצורה שהמערכות העורפיות יכולות לעבד.

אם אתם משלבים שירותים עורפיים, אתם לא צריכים להשקיע זמן בהבנת הפורמט של Dialogflow WebhookRequest. המדיניות ParseDialogflowRequest שמוכנה לשימוש מטפלת בעיבוד של נתוני הבקשה בצורה חלקה.

כדי לגשת אל WebhookRequest של סוכן Dialogflow ב-Apigee, צריך להגדיר את webhook URL (מילוי הבקשה) של הסוכן ל-ProxyEndpoint שהגדרתם ב-Apigee. ה-ProxyEndpoint צריך להיות נגיש לכולם. מידע נוסף מופיע במאמר בנושא דרישות של שירות webhook.

<ParseDialogflowRequest>

הגדרת מדיניות ParseDialogflowRequest.

ערך ברירת המחדל לא רלוונטי
חובה? חובה
סוג אובייקט מורכב
רכיב אב לא רלוונטי
רכיבי צאצא <DialogflowVersion>
<DisplayName>
<VariablePrefix>

בטבלה הבאה מפורט תיאור כללי של רכיבי המשנה שספציפיים למדיניות ParseDialogflowRequest:

רכיב צאצא חובה? תיאור
<VariablePrefix> אופציונלי מציין קידומת מותאמת אישית למשתני הזרימה.
<DialogflowVersion> אופציונלי מציינת את הגרסה של Dialogflow.

דוגמה

בדוגמה הבאה מוצגת בקשת webhook לדוגמה, מדיניות 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>

בקשת webhook

בדוגמה הבאה מוצגת בקשת ה-webhook (בפורמט JSON) מסוכן Dialogflow.

{
    "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 ואחריהם התחילית (my-prefix) כפי שצוין באלמנט <VariablePrefix>.

This element has the following attributes that are common to all policies:

Attribute Default Required? Description
name N/A Required

The internal name of the policy. The value of the name attribute can contain letters, numbers, spaces, hyphens, underscores, and periods. This value cannot exceed 255 characters.

Optionally, use the <DisplayName> element to label the policy in the management UI proxy editor with a different, natural-language name.

continueOnError false Optional Set to false to return an error when a policy fails. This is expected behavior for most policies. Set to true to have flow execution continue even after a policy fails. See also:
enabled true Optional Set to true to enforce the policy. Set to false to turn off the policy. The policy will not be enforced even if it remains attached to a flow.
async   false Deprecated This attribute is deprecated.

הפניה לרכיב צאצא

בקטע הזה מתוארים רכיבי הבן של <ParseDialogflowRequest>.

<DisplayName>

Use in addition to the name attribute to label the policy in the management UI proxy editor with a different, more natural-sounding name.

The <DisplayName> element is common to all policies.

Default Value N/A
Required? Optional. If you omit <DisplayName>, the value of the policy's name attribute is used.
Type String
Parent Element <PolicyElement>
Child Elements None

The <DisplayName> element uses the following syntax:

Syntax

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

Example

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

The <DisplayName> element has no attributes or child elements.

<VariablePrefix>

מציינים קידומת מותאמת אישית למשתני התהליך. הקידומת שמוגדרת ברכיב הזה מתווספת לכל שמות המשתנים שנוצרים על ידי מדיניות ParseDialogflowRequest. כברירת מחדל, הקידומת google.dialogflow מתווספת לכל המשתנים שנוצרים על ידי המדיניות. אם הגדרתם את הרכיב VariablePrefix, הקידומת המותאמת אישית שלכם מתווספת אחרי google.dialogflow. לכן, שם המשתנה מתחיל ב-google.dialogflow.CUSTOM_PREFIX.

אם לא מציינים את הרכיב VariablePrefix, שם המשתנה יתחיל רק ב-google.dialogflow.

ערך ברירת המחדל לא רלוונטי
חובה? אופציונלי
סוג String
רכיב אב <ParseDialogflowRequest>
רכיבי צאצא ללא
רכיב <VariablePrefix> משתמש בתחביר הבא:

תחביר

<VariablePrefix>VARIABLE_PREFIX</VariablePrefix>

דוגמה

בדוגמה הבאה, הערך של VariablePrefix מוגדר ל-my-prefix:

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

בהתאם להגדרה הזו, כל שמות המשתנים מתחילים ב-google.dialogflow.my-custom-prefix.

<DialogflowVersion>

מציינת את הגרסה של Dialogflow. המדיניות ParseDialogflowRequest תומכת רק בגרסה CX. אם לא מציינים את הרכיב הזה במדיניות, ברירת המחדל של הגרסה היא CX.

ערך ברירת המחדל לא רלוונטי
חובה? אופציונלי
סוג String
רכיב אב לא רלוונטי
רכיבי צאצא ללא
רכיב <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.

נושאים קשורים

הטמעות לדוגמה של פרוקסי Apigee ותהליכים משותפים שמציגים את השימוש במדיניות ParseDialogflowRequest זמינות ב-Apigee GitHub. מידע נוסף זמין במאמר בנושא הטמעות לדוגמה של AI בממשק שיחה.