跳至主要内容

Webhooks

此方法涉及設定和配置 webhook 以接收各種對話事件。這些事件包括來自使用者的新訊息以及有關外發訊息狀態的更新。

當發生 webhook 觸發時,將向已設定的 webhook URL 傳送包含 JSON 負載的 POST 請求。

請確保您的應用程式對 webhook 回應 200,以確保其正常運作。

此表列出了事件訊息類型的所有可能選項。

TypeDescription
MESSAGE_CREATEDNew message received by our platform
MESSAGE_DELIVERYDelivery status updates of one message
USER_EVENTUser related events like subscription
TEMPLATE_STATUS_UPDATETemplate status updates
TEMPLATE_CATEGORY_UPDATETemplate category updates

訊息傳送狀態

Conversations API 平台產生類型為 MESSAGE_DELIVERY 的事件通知,以提供先前傳送訊息的狀態更新。

訊息傳遞狀態代碼詳述如下(「status」參數)。

CodeDescription
DELIVEREDthe message was delivered to the user
READ.the message was read by the user
SENTthe message was sent to the provider
REJECTEDthe message was rejected by our platform
FAILEDthe message failed to be sent
EXPIREDthe message was not delivered in time
UNKNOWNthe message status is unknown

In case of unsuccessful message deliveries, the platform will provide specific error codes ('errorCode' parameter) to indicate the cause of the failure.

CodeDescription
1Unknown
2User Not Subscribed
3Price or Cost config Not Found
4An error with your media. Could be an unsupported file format, etc
5Free Test Quota Exceeded For Messages
6Channel server unreachable
7Monthly minimum fee not found
8Template error
9Quick Reply invalid item count, should be between 2 and 5
10Channel integration configuration not found
11Overloaded
12Your balance is not sufficient for this transaction
13Route configuration not found
14The business is not eligible or the template ID is not allowed for the business
15Not found registered device for the phone number or message undeliverable due user preferences / legal reason
16carrier network retry exceed
17API Request rejected
100User Not Found
300Country not allowed
301SMS request not success
302App Route configuration not found
303Channel is not activated

使用者事件

每當終端使用者變更其訂閱偏好時,我們的平台將推送一個類型為 USER_EVENT 的事件。

此表列出了事件訊息類型的所有可能選項。

TypeDescription
SUBSCRIBEDThe user has subscribed
UNSUBSCRIBEDThe user has unsubscribed
TAG_ASSIGNUser tag assignment has been updated

錯誤

如果 webhook 請求未成功,系統將在 15 分鐘內最多額外重試 3 次。

如果目標未傳回成功代碼(2XX)或不可解決的錯誤,每次重試之間的間隔將呈指數級增長。

此外,如果在 20 秒內沒有收到回應,系統將視為失敗並啟動重試。