이벤트

다음 예에서 rbm_api_helper.js (Python에는 사용되지 않음)는 작업 중인 파일이 기본 앱 폴더 아래에 있는 디렉터리 1개라고 가정합니다. 프로젝트 구성에 따라 위치를 조정해야 할 수도 있습니다.

이벤트 읽기

읽기 이벤트는 상담사가 메시지를 수신했음을 사용자에게 알리고 RBM 플랫폼에서 메시지를 전송했음을 확신시킵니다. 다음 코드는 클라이언트 라이브러리가 있는 기기로 읽기 이벤트를 전송합니다.

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Send the device an event to indicate that messageId has been read
rbmApiHelper.sendReadMessage('+12223334444', messageId);
이 코드는 RBM 샘플 에이전트의 발췌 부분입니다.

자바

import com.google.rbm.RbmApiHelper;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper();

// Send the device an event to indicate that messageId has been read
rbmApiHelper.sendReadMessage(messageId, "+12223334444");
이 코드는 RBM 샘플 에이전트의 발췌 부분입니다.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service

# Send the device an event to indicate that message_id was read
rbm_service.send_read_event('+12223334444', message_id)
이 코드는 RBM 샘플 에이전트의 발췌 부분입니다.

C#

using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

// Send the device an event to indicate that messageId has been read
rbmApiHelper.SendReadMessage(messageId, "+12223334444");
이 코드는 RBM 샘플 에이전트의 발췌 부분입니다.

입력 이벤트

입력 이벤트는 상담사가 메시지를 작성 중임을 사용자에게 알립니다. 다음 코드는 클라이언트 라이브러리가 있는 기기에 입력 이벤트를 전송합니다.

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('@google/rcsbusinessmessaging');

// Send the device an event to indicate that the agent is typing
rbmApiHelper.sendIsTypingMessage('+12223334444', function() {
    console.log('Typing event sent!');
});
이 코드는 RBM 샘플 에이전트의 발췌 부분입니다.

자바

import com.google.rbm.RbmApiHelper;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper();

// Send the device an event to indicate that the agent is typing
rbmApiHelper.sendIsTypingMessage("+12223334444");
이 코드는 RBM 샘플 에이전트의 발췌 부분입니다.

Python

# Reference to RBM Python client helper and messaging object structure
from rcs_business_messaging import rbm_service

# Send the device an event to indicate that the agent is typing
rbm_service.send_is_typing_event('+12223334444')
이 코드는 RBM 샘플 에이전트의 발췌 부분입니다.

C#

using RCSBusinessMessaging;


// Create an instance of the RBM API helper
RbmApiHelper rbmApiHelper = new RbmApiHelper(credentialsFileLocation,
                                                 projectId);

// Send the device an event to indicate that the agent is typing
rbmApiHelper.SendIsTypingMessage(messageId, "+12223334444");
이 코드는 RBM 샘플 에이전트의 발췌 부분입니다.