메시지 취소

에이전트는 전송되었지만 아직 전송되지 않은 메시지를 취소할 수 있습니다. 전송되지 않은 메시지가 비활성 상태가 되기 전에 취소하는 것이 가장 좋습니다. 시기는 에이전트의 사용 사례에 따라 다릅니다. 예를 들어 10분 후에 OTP 메시지를 취소하지만 특정 만료일에 프로모션 메시지를 취소할 수 있습니다. 메시지를 적시에 전송하려면 SMS와 같은 대체 경로를 통해 전송할 수 있도록 제때 메시지를 취소해야 합니다.

메시지를 취소하는 방법에는 두 가지가 있습니다.

  • 취소 요청을 전송하여 취소를 트리거합니다. RBM 플랫폼이 취소 요청을 수신하면 플랫폼은 200 OK를 반환합니다. 200 OK 응답은 메시지가 취소되었는지 여부를 확인하지 않습니다. 취소에 성공하면 RBM 플랫폼이 메시지 전송 시도를 중지하고 사용자의 대기열에서 삭제됩니다.

  • 메시지 만료를 설정하여 적절한 시점에 메시지를 자동으로 취소합니다. RBM 플랫폼은 메시지가 만료되었을 때 에이전트에 알리고 성공적으로 취소되었는지 확인합니다. 자세한 내용은 서버 생성 이벤트를 참고하세요.

드물지만 해지가 실패할 수 있습니다. 예를 들어 RBM 플랫폼이 메시지를 전송하는 동안 에이전트가 메시지를 취소하려고 할 수 있습니다. 취소에 실패하면 웹훅에서 DELIVERED 이벤트가 있는지 확인합니다. 메시지가 전송되지 않은 경우 새 취소 요청을 보낸 후 SMS와 같은 대체 채널로 메시지를 라우팅하여 적시에 전송할 수 있습니다.

다음 코드는 취소 요청을 보냅니다. 형식 지정 및 값 정보는 phones.agentMessages.delete를 참고하세요.

cURL

curl -X DELETE "https://REGION-rcsbusinessmessaging.googleapis.com/v1/phones/PHONE_NUMBER/agentMessages/MESSAGE_ID" \
-H "Content-Type: application/json" \
-H "User-Agent: curl/rcs-business-messaging" \
-H "`oauth2l header --json PATH_TO_SERVICE_ACCOUNT_KEY rcsbusinessmessaging`"

Node.js

// Reference to RBM API helper
const rbmApiHelper = require('../libs/rbm_api_helper');

// Stop the message associated with messageId from being delivered
rbmApiHelper.revokeMessage('+12223334444', messageId, function(err, response) {
   console.log(response);
});
이 코드는 RBM 샘플 상담사에서 발췌한 것입니다.

Java

import com.google.rbm.samples.lib.RbmApiHelper;
…

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

   // Stop the message associated with messageId from being delivered
   rbmApiHelper.revokeMessage(messageId, "+12223334444");
} catch(Exception e) {
   e.printStackTrace();
}
이 코드는 RBM 샘플 상담사에서 발췌한 것입니다.

Python

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

# Stop the message associated with message_id from being delivered
rbm_service.revoke('+12223334444', message_id)
이 코드는 RBM 샘플 상담사에서 발췌한 것입니다.

C#

using RCSBusinessMessaging;
…

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

// Stop the message associated with messageId from being delivered
rbmApiHelper.RevokeMessage(messageId, "+12223334444");
이 코드는 RBM 샘플 상담사에서 발췌한 것입니다.