Virtual Agent Assist

במדריך הזה מוסבר איך להפעיל את התכונה סיוע של סוכן וירטואלי באמצעות קריאה ישירה ל-API. העוזר הדיגיטלי Virtual Agent Assist עוקב אחרי השיחה ומשתמש בסוכן וירטואלי של Dialog Flow כדי לספק תמיכה בתהליכי עבודה לסוכנים אנושיים ולזהות כוונות לניתוח נתונים.

אם אתם מעדיפים, אתם יכולים להשתמש במסוף Agent Assist כדי לאמן מודל ולבדוק את הביצועים שלו באמצעות הסימולטור. הוראות מפורטות זמינות במדריך למסוף של Virtual Agent Assist.

לפני שמתחילים

כדי להפעיל את Virtual Agent Assist, צריך להטמיע קודם תכונה אחת או יותר של Agent Assist לשימוש עם הנציג הווירטואלי. אפשר להשתמש בתשובה מהירה, בעזרה בנושא שאלות נפוצות, בהצעות למאמרים ובכתיבה מהירה בנפרד עם Agent Assist וירטואלי או בכל שילוב. בקישורים הבאים אפשר לעבור לתיעוד הרלוונטי כדי לקבל פרטים על ההטמעה.

יצירת שיחה

כשמתחיל דיאלוג בין משתמש קצה לבין נציג אנושי או וירטואלי, נוצר שיחה. כדי לראות הצעות, צריך גם ליצור משתתף שהוא משתמש קצה ומשתתף שהוא נציג שירות אנושי, ולהוסיף אותם לשיחה. בקטעים הבאים מפורט תהליך ההגדרה.

קודם צריך ליצור שיחה:

REST

כדי ליצור שיחה, מבצעים קריאה ל-method‏ create במשאב Conversation.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט בענן
  • LOCATION_ID: מזהה המיקום
  • CONVERSATION_PROFILE_ID: המזהה שקיבלתם כשנוצר פרופיל השיחה

ה-method של ה-HTTP וכתובת ה-URL:

POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION_ID/conversations

תוכן בקשת JSON:

{
  "conversationProfile": "projects/PROJECT_ID/locations/LOCATION_ID/conversationProfiles/CONVERSATION_PROFILE_ID",
}

כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:

אתם אמורים לקבל תגובת JSON שדומה לזו:

{
  "name": "projects/PROJECT_ID/locations/LOCATION_ID/conversations/CONVERSATION_ID",
  "lifecycleState": "IN_PROGRESS",
  "conversationProfile": "projects/PROJECT_ID/locations/LOCATION_ID/conversationProfiles/CONVERSATION_PROFILE_ID",
  "startTime": "2018-11-05T21:05:45.622Z"
}

פלח הנתיב אחרי conversations מכיל את מזהה השיחה החדש.

Python

כדי לבצע אימות ב-Agent Assist, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

def create_conversation(project_id, conversation_profile_id):
    """Creates a conversation with given values

    Args:
        project_id:  The GCP project linked with the conversation.
        conversation_profile_id: The conversation profile id used to create
        conversation."""

    client = dialogflow.ConversationsClient()
    conversation_profile_client = dialogflow.ConversationProfilesClient()
    project_path = client.common_project_path(project_id)
    conversation_profile_path = conversation_profile_client.conversation_profile_path(
        project_id, conversation_profile_id
    )
    conversation = {"conversation_profile": conversation_profile_path}
    response = client.create_conversation(
        parent=project_path, conversation=conversation
    )

    print("Life Cycle State: {}".format(response.lifecycle_state))
    print("Conversation Profile Name: {}".format(response.conversation_profile))
    print("Name: {}".format(response.name))
    return response

יצירת משתתף שהוא משתמש קצה

כדי לראות הצעות, צריך להוסיף לשיחה גם משתמשי קצה וגם נציגים אנושיים. קודם מוסיפים את המשתמש הסופי לשיחה:

REST

כדי ליצור משתתף שהוא משתמש קצה, צריך לבצע קריאה ל-method‏ create במשאב Participant.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט בענן
  • LOCATION_ID: מזהה המיקום
  • CONVERSATION_ID: מזהה השיחה

ה-method של ה-HTTP וכתובת ה-URL:

POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION_ID/conversations/CONVERSATION_ID/participants

תוכן בקשת JSON:

{
  "role": "END_USER",
}

כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:

אתם אמורים לקבל תגובת JSON שדומה לזו:

{
  "name": "projects/PROJECT_ID/locations/LOCATION_ID/conversations/CONVERSATION_ID/participants/PARTICIPANT_ID",
  "role": "END_USER"
}

פלח הנתיב אחרי participants מכיל את מזהה המשתתף החדש של משתמש הקצה.

Python

כדי לבצע אימות ב-Agent Assist, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

def create_participant(project_id: str, conversation_id: str, role: str):
    from google.cloud import dialogflow_v2beta1 as dialogflow

    """Creates a participant in a given conversation.

    Args:
        project_id: The GCP project linked with the conversation profile.
        conversation_id: Id of the conversation.
        participant: participant to be created."""

    client = dialogflow.ParticipantsClient()
    conversation_path = dialogflow.ConversationsClient.conversation_path(
        project_id, conversation_id
    )
    if role in ROLES:
        response = client.create_participant(
            parent=conversation_path, participant={"role": role}, timeout=600
        )
        print("Participant Created.")
        print(f"Role: {response.role}")
        print(f"Name: {response.name}")

        return response

יצירת משתתף שהוא סוכן אנושי

הוספת נציג אנושי לשיחה:

REST

כדי ליצור משתתף שהוא נציג שירות אנושי, צריך להפעיל את method‏ create במשאב Participant.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט בענן
  • LOCATION_ID: מזהה המיקום
  • CONVERSATION_ID: מזהה השיחה

ה-method של ה-HTTP וכתובת ה-URL:

POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION_ID/conversations/CONVERSATION_ID/participants

תוכן בקשת JSON:

{
  "role": "HUMAN_AGENT",
}

כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:

אתם אמורים לקבל תגובת JSON שדומה לזו:

{
  "name": "projects/PROJECT_ID/locations/LOCATION_ID/conversations/CONVERSATION_ID/participants/PARTICIPANT_ID",
  "role": "HUMAN_AGENT"
}

פלח הנתיב אחרי participants מכיל את מזהה המשתתף החדש של הסוכן האנושי.

Python

כדי לבצע אימות ב-Agent Assist, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

def create_participant(project_id: str, conversation_id: str, role: str):
    from google.cloud import dialogflow_v2beta1 as dialogflow

    """Creates a participant in a given conversation.

    Args:
        project_id: The GCP project linked with the conversation profile.
        conversation_id: Id of the conversation.
        participant: participant to be created."""

    client = dialogflow.ParticipantsClient()
    conversation_path = dialogflow.ConversationsClient.conversation_path(
        project_id, conversation_id
    )
    if role in ROLES:
        response = client.create_participant(
            parent=conversation_path, participant={"role": role}, timeout=600
        )
        print("Participant Created.")
        print(f"Role: {response.role}")
        print(f"Name: {response.name}")

        return response

הוספת הודעה ממשתמש הקצה וקבלת הצעות

כדי להוסיף ולנתח הודעה של משתמש קצה בשיחה, צריך לבצע קריאה ל-method‏ analyzeContent במשאב Participant. התשובה כוללת את השדה dialogflowAssistAnswers שמכיל את הנתונים הבאים:

  • fulfillmentText: מכיל הצעה לתשובה. אתם יכולים להגדיר את המערכת כך שההצעה הזו תוצג לנציג האנושי.
  • answer record: מזהה ייחודי של ההצעה.

בוחרים את ההצעה.

כשנציג אנושי מקבל הצעה, הוא יכול לאשר אותה כמו שהיא או לערוך אותה לפני שהוא מעביר אותה למשתמש הקצה. כדי לבחור הצעה, מתקשרים שוב אל analyzeContent באמצעות המשתתף שהוא נציג אנושי. מגדירים את השדה suggestionInput להגדרות שבחרתם ומזינים את answer record שקיבלתם קודם. השדה text override צריך להכיל את הטקסט בפועל שנשלח למשתמש הקצה. דוגמה להגדרת השדה suggestionInput:

{
  "answerRecord": "answer-record",
  "textOverride": {
    "text" : "Yes, there will be ponies.",
    "languageCode": "en-US"
  }
}

סיום השיחה

בסיום השיחה, משתמשים ב-API כדי להשלים את השיחה.

REST

כדי להשלים את השיחה, מבצעים קריאה ל-method‏ complete במשאב conversations.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • PROJECT_ID: מזהה הפרויקט ב-GCP
  • CONVERSATION_ID: המזהה שקיבלתם כשפתחתם את השיחה

ה-method של ה-HTTP וכתובת ה-URL:

POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/conversations/CONVERSATION_ID:complete

כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:

אתם אמורים לקבל תגובת JSON שדומה לזו:

{
  "name": "projects/PROJECT_ID/conversations/CONVERSATION_ID",
  "lifecycleState": "COMPLETED",
  "conversationProfile": "projects/PROJECT_ID/conversationProfiles/CONVERSATION_PROFILE_ID",
  "startTime": "2018-11-05T21:05:45.622Z",
  "endTime": "2018-11-06T03:50:26.930Z"
}

Python

כדי לבצע אימות ב-Agent Assist, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

def complete_conversation(project_id, conversation_id):
    """Completes the specified conversation. Finished conversations are purged from the database after 30 days.

    Args:
        project_id: The GCP project linked with the conversation.
        conversation_id: Id of the conversation."""

    client = dialogflow.ConversationsClient()
    conversation_path = client.conversation_path(project_id, conversation_id)
    conversation = client.complete_conversation(name=conversation_path)
    print("Completed Conversation.")
    print("Life Cycle State: {}".format(conversation.lifecycle_state))
    print("Conversation Profile Name: {}".format(conversation.conversation_profile))
    print("Name: {}".format(conversation.name))
    return conversation