이벤트

다음 예에서 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 샘플 에이전트에서 가져온 것입니다.