Virtual Agent Assist

Panduan cara ini akan memandu Anda melalui proses mengaktifkan fitur Bantuan Agen Virtual dengan memanggil API secara langsung. Asisten Agent Assist Virtual mengikuti percakapan dan menggunakan agen virtual Dialogflow untuk memberikan dukungan alur kerja kepada agen manusia dan mendeteksi maksud untuk analisis data.

Jika mau, Anda dapat menggunakan konsol Agent Assist untuk melatih model dan menguji performanya menggunakan simulator. Lihat tutorial konsol Virtual Agent Assist untuk mendapatkan petunjuk.

Sebelum memulai

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

Buat percakapan

Saat dialog dimulai antara pengguna akhir dan agen manusia atau agen virtual, Anda membuat percakapan. Untuk melihat saran, Anda juga harus membuat peserta pengguna akhir dan peserta agen manusia, lalu menambahkannya 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 agen manusia dan pengguna akhir 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 di 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:

  • fulfillmentText: Berisi respons yang disarankan. Anda dapat mengonfigurasi sistem untuk menampilkan saran ini kepada agen manusia.
  • answer record: ID unik untuk saran.

Pilih saran

Saat menerima saran, agen manusia dapat menerimanya apa adanya atau mengeditnya sebelum meneruskannya kepada pengguna akhir. Untuk memilih saran, panggil analyzeContent lagi menggunakan peserta agen manusia. Tetapkan kolom suggestionInput ke setelan yang Anda pilih dan berikan answer record yang Anda terima sebelumnya. Kolom text override harus berisi teks sebenarnya yang dikirim ke pengguna akhir. Berikut adalah contoh konfigurasi 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