イベントを送信する

エージェントは、人間のやり取りをシミュレートするために、ステータス イベントをユーザーのデバイスに送信します。ユーザーには、これらのイベントが開封確認または入力インジケーターとして表示され、メッセージが処理されていることを確認できます。

完全な書式設定と値のオプションについては、phones.agentEvents リファレンスをご覧ください。

エージェントが RBM プラットフォームから受信する webhook イベントの詳細については、 イベントを受信するをご覧ください。

エージェントが READ イベントを送信する

ユーザーには、このイベントが特定のメッセージの開封確認として表示されます。これにより、RBM プラットフォームがメッセージを配信し、エージェントがメッセージを処理していることをユーザーに知らせることができます。

READ イベントは永続化され、30 日間保存されます。ユーザーが RCS を有効にしているが、到達できない場合、イベントはキューに登録されます。RCS を有効にしていない場合、RCS for Business プラットフォームは NOT_FOUND(HTTP 404)エラーを返します。

次のコードは、一致する messageId を持つメッセージの READ イベントを送信します。

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentEvents?eventId=EVENT_ID&agentId=AGENT_ID" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/rcs-business-messaging" \
-H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \
-d "{
  'eventType': 'READ',
  'messageId': 'MESSAGE_ID'
}"

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 サンプル エージェントからの抜粋です。

Java

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 サンプル エージェントからの抜粋です。

エージェントが IS_TYPING イベントを送信する

ユーザーには、このイベントが入力インジケーターとして表示され、エージェントがメッセージを作成していることを知らせます。入力インジケーターは、短時間(約 20 秒)経過するか、ユーザーのデバイスがエージェントから新しいメッセージを受信すると期限切れになります。エージェントは複数の IS_TYPING イベントを送信して、入力インジケーターの有効期限タイマーをリセットできます。

IS_TYPING イベントは一時的なものであり、キューに登録されません。

次のコードは、IS_TYPING イベントを送信します。

cURL

curl -X POST "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentEvents?eventId=EVENT_ID&agentId=AGENT_ID" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/rcs-business-messaging" \
-H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`" \
-d "{
  'eventType': 'IS_TYPING',
}"

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 サンプル エージェントからの抜粋です。

Java

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 サンプル エージェントからの抜粋です。