이벤트

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

이벤트 읽기

읽음 이벤트는 상담사가 메시지를 수신했음을 사용자에게 알리고 비즈니스용 RCS 플랫폼이 메시지를 전송했다는 확신을 제공합니다. 다음 코드는 클라이언트 라이브러리를 사용하여 기기에 읽기 이벤트를 전송합니다.

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 샘플 에이전트에서 발췌한 것입니다.