메시지 취소

상담사는 전송되었지만 아직 전송되지 않은 메시지를 취소할 수 있습니다. 전송되지 않은 메일이 비활성화되기 전에 취소하는 것이 가장 좋습니다. 타이밍은 상담사의 사용 사례에 따라 다릅니다. 예를 들어 OTP 메시지는 10분 후에 취소하지만 프로모션 메시지는 특정 만료일에 취소할 수 있습니다. 메일을 제때 전송하려면 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?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`"

Node.js

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

// Stop the message associated with messageId from being delivered
rbmApiHelper.revokeMessage('+12223334444', messageId, function(err, response) {
   console.log(response);
});
이 코드는 RBM 샘플 에이전트의 발췌 부분입니다.

자바

import com.google.rbm.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 샘플 에이전트의 발췌 부분입니다.