메시지 취소

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

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

  • 취소 요청을 보냅니다 취소를 트리거합니다. 200 OK 응답은 메시지가 취소되고 사용자의 대기열에서 삭제되었음을 확인합니다. 404 Not Found 응답은 메시지가 전송되었으므로 취소 시도가 실패했음을 의미합니다.

  • 메시지 만료를 설정 하여 적절한 시간에 메시지를 자동으로 취소합니다. 메시지가 만료되면 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 샘플 에이전트의 일부입니다.