에이전트의 반응을 유도하기 위해 비언어적 신호를 보내다

이 튜토리얼에서는 채팅 UI에 트리거 메시지를 표시하지 않고도 사일런트 메시지를 사용하여 에이전트의 응답을 유도하는 방법을 설명합니다. 무음 메시지는 처리를 위해 에이전트로 전송되지만 사용자에게는 표시되지 않으므로, 상호작용을 자동화하고 사용자 행동을 추적하는 데 이상적입니다.

다음과 같은 상황에서는 비공개 메시지 사용을 고려해 보세요:

  • 환영 메시지 트리거 : 채팅이 로드될 때 인사말이 표시되도록 빈 무음 메시지를 전송합니다.

  • 사용자 행동 추적 : 사용자가 버튼을 클릭하거나 특정 페이지로 이동할 때 상담원에게 알림을 보냅니다.

  • 시스템 알림 전송 : 백그라운드 이벤트나 시스템 상태 변경 사항을 상담원에게 알립니다.

  • 피드백 처리 기능 구현 : 채팅창에 시스템 메시지를 표시하지 않고도 사용자 피드백을 확인합니다.

무음 메시지의 작동 원리

무음 메시지를 보낼 때 다음과 같은 작업이 수행됩니다:

  • 메시지가 처리를 위해 에이전트로 전송됩니다.

  • 해당 메시지는 채팅 화면에서 숨겨져 있습니다.

  • 에이전트는 해당 메시지에 응답할 수 있습니다(응답 내용은 사용자에게 표시됩니다).

  • 사용자는 트리거 메시지가 아닌 상담원의 응답만 볼 수 있습니다.

이 기법은 대화를 복잡하게 만들지 않으면서 환영 메시지를 표시하고, 사용자 행동을 추적하며, 시스템 알림을 전송하고, 피드백 흐름을 구현하는 데 유용합니다.

해당 silent 옵션의 기본 규칙 및 동작에 대해서는 를 참조하십시오 instance.send().

1단계: 간단한 무음 메시지 보내기

메서드에 instance.send() 옵션을 { silent: true } 지정하여 채팅 UI에 표시되지 않는 메시지를 전송합니다.

// Send a visible message
await instance.send('Hello, how can you help me?');

// Send a silent message (hidden from UI)
await instance.send('User clicked help button', { silent: true });

채팅이 로드될 때 환영 메시지를 표시하려면, 내용 없는 비공개 메시지를 보내세요:

await instance.send('', { silent: true });

2단계: 무음 메시지를 통해 사용자 행동 추적하기

채팅 창에 알림이 표시되지 않도록 하여, 사용자 상호작용을 상담원에게 알리려면 비공개 메시지를 사용하세요. 이 예제는 사용자가 특정 페이지를 볼 때 알림 없이 메시지를 전송합니다:

await instance.send('User viewed pricing page', { silent: true });

또한 사용자 피드백을 처리하고 이를 에이전트에게 자동으로 전송하는 함수를 만들 수도 있습니다:

async function handleFeedback(rating, comment) {
    const message = `User feedback: ${rating} stars - ${comment}`;
    await instance.send(message, { silent: true });
}

3단계: 고급 제어를 위해 MessageRequest 를 사용하세요

메시지 속성을 더 세밀하게 제어하려면 ` MessageRequest ` 객체의 ` skip_render property` 속성을 사용하세요. 이 방법은 추가적인 맥락을 명시하거나 메시지 동작을 사용자 정의해야 할 때 유용합니다:

await instance.send({
    message: {
        role: 'user',
        content: 'User clicked help button',
        additional_properties: {
            display_properties: {
                skip_render: true  // Hide from UI
            }
        }
    }
});

무음 메시지에 사용자 정의 컨텍스트 데이터를 포함할 수도 있습니다:

await instance.send({
    message: {
        role: 'user',
        content: 'I need help with my order',
        additional_properties: {
            display_properties: {
                skip_render: true
            }
        }
    },
    context: {
        user_location: 'checkout_page',
        cart_value: 150.00
    }
});

전체 대본

채팅 위젯에 무음 메시지 기능을 구현하려면 다음 스크립트를 사용하세요. 이 예제는 채팅이 로드될 때 환영 메시지를 표시합니다:


function onChatLoad(instance) {
    // Send a silent message to trigger a welcome response
    instance.send('', { silent: true });
    
    // Store the chat instance globally if needed
    chatInstance = instance;
}

window.wxOConfiguration = {
    orchestrationID: "your-orgID_orchestrationID",
    hostURL: "https://dl.watson-orchestrate.ibm.com",
    rootElementID: "root",
    showLauncher: false,
    deploymentPlatform: "ibmcloud", // Required for IBM Cloud 
    crn: "your-org-crn", // Required for IBM Cloud. Learn how to get the CRN in https://cloud.ibm.com/docs/key-protect?topic=key-protect-retrieve-instance-ID&interface=ui
    chatOptions: {
        agentId: "your-agent-id",
        agentEnvironmentId: "your-agent-env-id",
        onLoad: onChatLoad // Callback function when the chat widget is loaded
    },
};
setTimeout(function () {
    const script = document.createElement('script');
    script.src = `${window.wxOConfiguration.hostURL}/wxochat/wxoLoader.js?embed=true`;
    script.addEventListener('load', function () {
        wxoLoader.init();
    });
    document.head.appendChild(script);
}, 0);