Virtual Agent Assist

Agent Assist Virtual mengikuti percakapan dan menggunakan agen virtual Dialogflow untuk memberikan dukungan alur kerja kepada agen manusia dan mendeteksi intent untuk analisis data. Panduan ini akan memandu Anda melalui proses mengaktifkan fitur Agent Assist Virtual dengan memanggil API secara langsung. Lihat tutorial konsol Virtual Agent Assist untuk mengetahui petunjuk cara menggunakan konsol.

Sebelum memulai

Sebelum dapat mengaktifkan Virtual Agent Assist, Anda harus sudah menerapkan satu atau beberapa fitur Agent Assist untuk digunakan dengan agen virtual. Smart Reply, FAQ Assist, Saran Artikel, dan Smart Compose dapat digunakan sendiri dengan Virtual Agent Assist atau dalam kombinasi apa pun. Link berikut akan mengarahkan Anda ke dokumentasi yang relevan untuk mengetahui detail implementasi.

Membuat percakapan

Saat dialog dimulai antara pengguna akhir dan agen manusia atau virtual, Anda membuat percakapan. Untuk melihat saran, Anda juga harus membuat peserta pengguna akhir dan peserta agen manusia, lalu menambahkan mereka ke percakapan. Bagian berikut akan memandu Anda melalui proses ini.

Pertama, Anda harus membuat percakapan:

REST

Untuk membuat percakapan, panggil metode create pada resource Conversation.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • PROJECT_ID: project ID Cloud Anda
  • LOCATION_ID: ID lokasi Anda
  • CONVERSATION_PROFILE_ID: ID yang Anda terima saat membuat profil percakapan

Metode HTTP dan URL:

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

Meminta isi JSON:

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

Untuk mengirim permintaan Anda, perluas salah satu opsi berikut:

Anda akan melihat respons JSON seperti berikut:

{
  "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"
}

Segmen jalur setelah conversations berisi ID percakapan baru Anda.

Python

Untuk melakukan autentikasi ke Agent Assist, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

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

Membuat peserta pengguna akhir

Anda harus menambahkan peserta pengguna akhir dan agen manusia ke percakapan untuk melihat saran. Pertama, tambahkan peserta pengguna akhir ke percakapan:

REST

Untuk membuat peserta pengguna akhir, panggil metode create pada resource Participant.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • PROJECT_ID: project ID Cloud Anda
  • LOCATION_ID: ID lokasi Anda
  • CONVERSATION_ID: ID percakapan Anda

Metode HTTP dan URL:

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

Meminta isi JSON:

{
  "role": "END_USER",
}

Untuk mengirim permintaan Anda, perluas salah satu opsi berikut:

Anda akan melihat respons JSON seperti berikut:

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

Segmen jalur setelah participants berisi ID peserta pengguna akhir baru Anda.

Python

Untuk melakukan autentikasi ke Agent Assist, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

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

Membuat peserta agen manusia

Menambahkan peserta agen manusia ke percakapan:

REST

Untuk membuat peserta agen manusia, panggil metode create pada resource Participant.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • PROJECT_ID: project ID Cloud Anda
  • LOCATION_ID: ID lokasi Anda
  • CONVERSATION_ID: ID percakapan Anda

Metode HTTP dan URL:

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

Meminta isi JSON:

{
  "role": "HUMAN_AGENT",
}

Untuk mengirim permintaan Anda, perluas salah satu opsi berikut:

Anda akan melihat respons JSON seperti berikut:

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

Segmen jalur setelah participants berisi ID peserta agen manusia baru Anda.

Python

Untuk melakukan autentikasi ke Agent Assist, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

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

Menambahkan pesan dari pengguna akhir dan mendapatkan saran

Untuk menambahkan dan menganalisis pesan pengguna akhir untuk percakapan, panggil metode analyzeContent pada resource Participant. Respons mencakup kolom dialogflowAssistAnswers yang berisi data berikut:

  • intentSuggestion: Berisi informasi tentang intent yang cocok, seperti nama tampilannya.
  • answerRecord: Nama resource unik dari data jawaban untuk saran.

Pilih saran

Saat menerima saran, agen manusia dapat memilihnya untuk memulai fulfillment untuk intent tersebut. Untuk memilih saran , panggil metode analyzeContent lagi dengan peserta agen manusia. Dalam isi permintaan untuk Dialogflow CX, tetapkan kolom suggestionInput dengan nilai answerRecord yang Anda terima dari saran. Memilih saran akan menerapkan fulfillment dan menampilkan pesan respons fulfillment. Dialogflow ES mengevaluasi fulfillment saat saran dibuat dan ditampilkan di queryResult. Memanggil analyzeContent dengan suggestionInput hanya akan mengupdate konteks sesi.

Jika agen manusia mengedit saran sebelum mengirimkannya kepada pengguna akhir, Anda juga dapat menentukan kolom textOverride opsional. Contoh berikut menunjukkan cara mengonfigurasi kolom suggestionInput:

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

Menyelesaikan percakapan

Saat percakapan berakhir, gunakan API untuk menyelesaikan percakapan.

REST

Untuk menyelesaikan percakapan, panggil metode complete pada resource conversations.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • PROJECT_ID: project ID GCP Anda
  • CONVERSATION_ID: ID yang Anda terima saat membuat percakapan

Metode HTTP dan URL:

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

Untuk mengirim permintaan Anda, perluas salah satu opsi berikut:

Anda akan melihat respons JSON seperti berikut:

{
  "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

Untuk melakukan autentikasi ke Agent Assist, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

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