Webhook API Doc
Webhook API Doc
Interface access specifications
Interactive process
Interface request security
Contact the administrator to obtain the key (obtained by the Moppo operation treasure background)
The interface request encryption method
1、tenant_id+timestamp+The key is treated as a signature string(access_token),use HmacSHA256 The algorithm computes the signature.
String appSecret = "f9a40a4780f5e1306c46f1c8daecee3b";
String tenantId = "500975";
String timestamp = "1666942813620";
String message = tenantId + timestamp ;
String access_token = HmacSHA256Util.hmacSHA256(appSecret,message);
// str = df98eda524132837317c5ea7e4f67ef4224dedc3f01548b6cb211b08eb0328c5
Permission control
Available to Pro users only
HTTP status code
Code | Description |
---|---|
200 | success! |
Common parameters
Attribute | Type | Required | Description |
---|---|---|---|
accessToken | String | yes | token |
tenantId | Integer | yes | tenant id |
timestamp | Long | yes | timestamp |
Callback verification
1、The callback request will validate the yes parameter, verify the correctness of appSecret, and verify the timestamp timestamp range (within the next minute after receiving the request).
2、The callback request must ensure that after the data synchronization is completed, the callback request must not be made in the synchronized URL interface, otherwise it will not take effect, and the synchronous URL interface must respond within three seconds, otherwise it will be directly regarded as a notification failure.
Code | Description |
---|---|
502 | TenantId Is Null |
503 | Timestamp Is Null |
504 | AccessToken Is Null |
505 | SuccessData or FailData Is Null |
506 | The configuration information is not enabled or deleted |
507 | Signature is incorrect |
508 | Timestamp timeout |
509 | Database Exception |
511 | no api key |
List of interfaces
Notice of modification of user portrait information
描述 pc 端客户修改用户画像(基本信息、扩展 Attribute)
Request Params
Attribute Type Required Description accessToken String yes token callBackUrl String yes callback url(post) tenantId Integer yes tenant id timestamp Long yes timestamp data List yes data - data:
Attribute Type Required Description id String yes id (uuid) userName String yes user name type Integer yes Type 1、User portrait modification 2、 Write a follow-up friendWhatsId String yes friend whatsapp id field String yes update Attribute ,extend Attribute Attribute name like: extend-file fieldType Integer yes Attribute Type 0、basic Attribute extend Attribute fieldConfig Integer yes Attribute config 1、Single line of text 2、Multiple lines of text 3、Radio 4、Multiple selection 5、numeric value 6、date 7、time 8、file sourceValue String no update old value targetValue String no update result updateAt String yes update time - Request Params:
{ "accessToken": "83293d01dddd628e3b457142f8a48a0cf4dae3b587e7febea7effea6bdcfd344", "callBackUrl": "http://192.168.2.23:10003/wscrm-bus-api/part/callback/portrait", "tenantId": 500975, "timestamp": 1667293135274, "data": [ { "id": "a0cb1ad15ed24e618b4b12d9cdff1ad4", "type": 1, "userName": "rose", "friendWhatsId": "8615601882491", "field": "Address", "fieldType": 0, "fieldConfig": 1, "sourceValue": "", "targetValue": "123123", "updateAt": "2022-09-29 20:34:58" }, { "id": "81c968134be648e19187db83efa60152", "type": 1, "userName": "jack", "friendWhatsId": "8615601882491", "field": "Gender", "fieldType": 0, "fieldConfig": 3, "sourceValue": "MALE", "targetValue": "FEMALE", "updateAt": "2022-10-02 20:34:58" }, { "id": "4d8ac8a3a5164ab2b066dcf8fac5bd45", "type": 2, "userName": "lee", "friendWhatsId": "33758618170", "field": "Follow up records", "fieldType": 0, "fieldConfig": 1, "sourceValue": "", "targetValue": "{\"data\":{\"text\":\"hello\",\"url\":[]},\"dataTypeMap\":{\"writeFollow\":\"write flow\"}}", "updateAt": "2022-10-31 17:44:06" } ] }
Follow up records:
fieldType、fieldConfig、fieldType The above are initial values
Write a follow-up sourceValue、 targetValue is a fixed format data: data(text: follow text,url:file upload url) 、dataTypeMap(value fixed format) Type
field
fieldConfig:is the data identified by us value Type、You can choose not to receive, not necessary Attribute
field | fieldConfig | Description(sourceValue ->targetValue) |
---|---|---|
Name | Single line of text | ex:jack ->lee |
Gender | Radio | MALE、FEMALE、UNKOWNN ex:MALE -> FEMALE |
DOB | Date | yyyy-MM-dd ex:2022-12-01-> 2022-12-02 |
Address | Single line of text | ex: new york-> Los Angeles |
Single line of text | ex: 123@gmail.com-> 123@gmail.com | |
Position | Single line of text | ex: Operations - > sales |
Income | Single line of text | ex: 10000$->20000$ |
Description | Single line of text | (include \n) ex: 1\n2\n3 -> 1\n2\n3\n4 |
From | Radio | According to the background customer management - settings ex:default -> Self-mining |
State | Radio | According to the background customer management - settings ex:new -> Demand matching |
Language | Radio | According to the background customer management - settings ex:auto -> am |
Tags | Multiple selection | According to the background customer management - settings ex:[tag-1] -> [tag-1,tag-2] |
MultipleSelection | Multiple selection | According to the background customer management - settings ex:[ms-1] -> [ms-1,ms-2] |
Time | Time | HH:mm:ss ex:17:26:59-> 17:27:35 |
File | File | http format ex:http://123.img,http://456.img |
Response data
Attribute Type Required Description code int yes code message String yes message data String yes data - Example:
{ "code": 200, "message": "", "data": "" }
Callback check
Attribute | Type | Required | Description |
---|---|---|---|
tenantId | Integer | yes | tenant id |
timestamp | Long | yes | timestamp |
accessToken | String | yes | token |
successData | List | yes | success callback ids |
failData | List | yes | error callback ids |
- Request example:
{
"tenantId": 1,
"timestamp": 1665658642000,
"accessToken": "CD1D8EDA200DD8FC21888F7F241C01ACC8F1D30966D9B8BAB5F303789EE81D09",
"successData": ["e496772197514188abd6cbf1dfb23102", "e49677219..."],
"failData": ["e496772197514188abd6cbf1d231231", "e4967dd9..."]
}
- Response Example:
{
"code": 200,
"message": "",
"data": ""
}
Message synchronization notification
description
The client sends and receives messages synchronously
- 1、send message
- 2、recv message
- 3、group send
- 4、message status(1-not upload WhatsApp、2-has upload WhatsApp、3-has send、4-has read)
Request Params
Attribute Type Required Description accessToken String yes token callBackUrl String yes callback url(post) tenantId Integer yes tenant id timestamp Long yes timestamp data List yes data data:
Attribute Type Required Description id String yes id (uuid) messageId String yes message id userName String yes user name whatsId String yes send whatsapp id friendWhatsId String yes friend whatsapp id currentWhatsId String yes current whatsapp actionType Integer yes action Type 1、send msg 2、 recv msg chatType Integer yes chatType 1、chat 2、 group chat messageStatus Integer yes message status 0、not upload WhatsApp 1、upload WhatsApp 2、has send 3、has read content String yes content contentType Integer yes Type 0、normal text 1、pic 2、video 3、audio 4、file sendTime String yes send time originType Integer yes origin type 1、pc 2、app 3、web
When the data parameter messageStatus changes, the state is resynchronized, and everything else remains unchanged
content:
Attribute Type Required Description filename String yes file name url String yes file url mimeType String yes mime Type caption String yes description When Type is 1,2,3,4 :
1 pic: image/jpeg、image/png、image/webp
2 video: video/mp4
3 audio: audio/aac、audio/m4a、audio/amr、audio/mpeg、audio/ogg; codecs=opus、codecs=opus
4 file: application/pdf、application/msword、application/ppt、application/xls
Request params:
{
"accessToken": "e6e18763d8212d26ced4f92512881c63c468d5a756d45c01486d7ad6742152ac",
"callBackUrl": "http://192.168.2.23:10003/wscrm-bus-api/part/callback/message",
"tenantId": 1238,
"timestamp": 1667295870936,
"data": [
{
"id": "30e873ab8f4840e2b610c414fe967327",
"messageId": "7a324c7b5512468cb7a9296af0f8379b",
"userName": "gdkj002",
"whatsId": "8617633819542@c.us",
"friendWhatsId": "8615601882491@c.us",
"currentWhatsId": "8617633819542@c.us",
"actionType": 1,
"chatType": 1,
"messageStatus": 1,
"content": "bye",
"contentType": 0,
"originType": 1,
"sendTime": "2022-10-31 16:25:42"
},
{
"id": "31057e55b9f842b4becf4a9ff699b64e",
"messageId": "82bfefadceb948428fd3f3ef659e14b3",
"userName": "gdkj002",
"whatsId": "8617633819542@c.us",
"friendWhatsId": "8615601882491@c.us",
"currentWhatsId": "8617633819542@c.us",
"actionType": 1,
"chatType": 1,
"messageStatus": 1,
"content": "{"caption":"","filename":"","mimetype":"video/mp4","url":"https://image.whatsappscrm.com/client/603704/chat_history/1665198225749_video"}",
"contentType": 2,
"originType": 1,
"sendTime": "2022-10-31 16:25:42"
}
]
}
Response data
Attribute Type Required Description code int yes code message String yes message data String yes data Response Example:
{ "code": 200, "message": "", "data": "" }
2.1 Callback validation
Attribute | Type | Required | Description |
---|---|---|---|
tenantId | Integer | yes | tenant id |
timestamp | Long | yes | timestamp |
accessToken | String | yes | token |
successData | List | yes | success callback ids |
failData | List | yes | error callback ids |
- Request Params:
{
"tenantId": 500975,
"timestamp": 1666942055897,
"accessToken": "cb2809b756cb2b2c47dd22581e832e0a0a204299787499ef405ebfa908382fbc",
"successData": [
"21cd1d0bddc74786b1f6a66b70154c94",
"3a5e458fc5494b0eb9686d1833c7fe0c",
"595e6ac326fe43b89cf3ec00c0904fc2",
"652b2704faaa43359b1fdf5c76b2fa4a",
"81c968134be648e19187db83efa60152",
"a0cb1ad15ed24e618b4b12d9cdff1ad4"
],
"failData": []
}
- Response Example:
{
"code": 200,
"message": "",
"data": ""
}
Group behavior buried point notification
When WhatsApp triggers the action of joining and leaving the group, it actively pushes and notifies members of the log of joining and leaving the group
Push data
- Request params
Attribute | Type | Required | Description |
---|---|---|---|
accessToken | String | yes | token |
callBackUrl | String | yes | callback url(post) |
tenantId | Integer | yes | tenant id |
timestamp | Long | yes | timestamp |
data | List | yes | data |
- data
Attribute | Type | Required | Description |
---|---|---|---|
id | String | yes | id (uuid) |
friendWhatsId | String | yes | friend whatsapp |
actionType | Integer | yes | 1 join group 2 left group |
createTime | String | yes | current time |
groupWhatsId | String | yes | group whatsapp ID |
groupLink | String | no | group link |
Request example
{
"accessToken": "e6e18763d8d5a756d45c01486d7ad6742152ac",
"callBackUrl": "host/wscrm-bus-api/part/callback/groupAction",
"tenantId": 1238,
"timestamp": 1667295870936,
"data": [
{
"id": "30e873ab8f4840e2b610c414fe967327",
"friendWhatsId": "8617633819542",
"actionType": 1,
"create_time": "2023-02-01 00:00:00",
"groupWhatsId": "120xxxxx",
"groupLink": "https://chat.xxx.com/CEwwCoiy7Qa1MVKex3x4p4"
}
]
}
Response example
{
"code": 200,
"message": "Success",
"data": ""
}
Push status callback to the advance and retreat group logs
Description: After receiving the push to join or leave the group, you need to call back the operation treasure to indicate that the push has been received
Callback check
Attribute | Type | Required | Description |
---|---|---|---|
tenantId | Integer | yes | tenant id |
timestamp | Long | yes | timestamp |
token | String | yes | token |
successData | List | yes | success callback ids |
failData | List | yes | error callback ids |
Request params
{
"tenantId": 123456,
"timestamp": 1666942055897,
"token": "cb2809b756cb2b2c47dd22581e83799ef405ebfa9083123456fbc",
"successData": [
"21cd1d0bddc74786b1f6a66b70154c94",
"3a5e458fc5494b0eb9686d1833c7fe0c",
"595e6ac326fe43b89cf3ec00c0904fc2",
"652b2704faaa43359b1fdf5c76b2fa4a",
"81c968134be648e19187db83efa60152",
"a0cb1ad15ed24e618b4b12d9cdff1ad4"
],
"failData": []
}
Response Example
{
"code": 200,
"message": "Success",
"data": ""
}
Notice of agent behavior burial
Frequently asked questions
The number of notification failure retries
Note: After the notification is synchronized, the status code that does not respond or is not 200 fails, and the WebHook configuration information of the type will be closed more than 5 times.
Retry interval, number of retries
Note: Failed requests will be retried processing The retry policy will be retried directly, a second retry after 10 minutes, a retry after 20 minutes for the third failure, and so on for a total of five times, if one of them succeeds, the configuration switch will be turned back on. If it fails five times, the retry operation is canceled. Change the message to sync failed.
- Configure how shutdown is handled
Note: After closing the configuration, data collection is still carried out but not synchronized, and when the configuration is opened, it is detected at intervals of 10 minutes, and all historical data is synchronized after it is detected.
time zone
UTC+8