Skip to main content

Webhook API Doc

About 5 min

Webhook API Doc

Interface access specifications

Interactive process

webhook Callback business time series diagram

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

CodeDescription
200success!

Common parameters

AttributeTypeRequiredDescription
accessTokenStringyestoken
tenantIdIntegeryestenant id
timestampLongyestimestamp

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.

CodeDescription
502TenantId Is Null
503Timestamp Is Null
504AccessToken Is Null
505SuccessData or FailData Is Null
506The configuration information is not enabled or deleted
507Signature is incorrect
508Timestamp timeout
509Database Exception
511no api key

List of interfaces

Notice of modification of user portrait information

描述 pc 端客户修改用户画像(基本信息、扩展 Attribute)

  • Request Params

    AttributeTypeRequiredDescription
    accessTokenStringyestoken
    callBackUrlStringyescallback url(post)
    tenantIdIntegeryestenant id
    timestampLongyestimestamp
    dataListyesdata
    • data:
    AttributeTypeRequiredDescription
    idStringyesid (uuid)
    userNameStringyesuser name
    typeIntegeryesType 1、User portrait modification 2、 Write a follow-up
    friendWhatsIdStringyesfriend whatsapp id
    fieldStringyesupdate Attribute ,extend Attribute Attribute name like: extend-file
    fieldTypeIntegeryesAttribute Type 0、basic Attribute extend Attribute
    fieldConfigIntegeryesAttribute 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
    sourceValueStringnoupdate old value
    targetValueStringnoupdate result
    updateAtStringyesupdate 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

fieldfieldConfigDescription(sourceValue ->targetValue)
NameSingle line of textex:jack ->lee
GenderRadioMALE、FEMALE、UNKOWNN ex:MALE -> FEMALE
DOBDateyyyy-MM-dd ex:2022-12-01-> 2022-12-02
AddressSingle line of textex: new york-> Los Angeles
EmailSingle line of textex: 123@gmail.com-> 123@gmail.com
PositionSingle line of textex: Operations - > sales
IncomeSingle line of textex: 10000$->20000$
DescriptionSingle line of text(include \n) ex: 1\n2\n3 -> 1\n2\n3\n4
FromRadioAccording to the background customer management - settings ex:default -> Self-mining
StateRadioAccording to the background customer management - settings ex:new -> Demand matching
LanguageRadioAccording to the background customer management - settings ex:auto -> am
TagsMultiple selectionAccording to the background customer management - settings ex:[tag-1] -> [tag-1,tag-2]
MultipleSelectionMultiple selectionAccording to the background customer management - settings ex:[ms-1] -> [ms-1,ms-2]
TimeTimeHH:mm:ss ex:17:26:59-> 17:27:35
FileFilehttp format ex:http://123.img,http://456.img
  • Response data

    AttributeTypeRequiredDescription
    codeintyescode
    messageStringyesmessage
    dataStringyesdata
    • Example:
    {
      "code": 200,
      "message": "",
      "data": ""
    }
    

Callback check

AttributeTypeRequiredDescription
tenantIdIntegeryestenant id
timestampLongyestimestamp
accessTokenStringyestoken
successDataListyessuccess callback ids
failDataListyeserror 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

    AttributeTypeRequiredDescription
    accessTokenStringyestoken
    callBackUrlStringyescallback url(post)
    tenantIdIntegeryestenant id
    timestampLongyestimestamp
    dataListyesdata

    data:

    AttributeTypeRequiredDescription
    idStringyesid (uuid)
    messageIdStringyesmessage id
    userNameStringyesuser name
    whatsIdStringyessend whatsapp id
    friendWhatsIdStringyesfriend whatsapp id
    currentWhatsIdStringyescurrent whatsapp
    actionTypeIntegeryesaction Type 1、send msg 2、 recv msg
    chatTypeIntegeryeschatType 1、chat 2、 group chat
    messageStatusIntegeryesmessage status 0、not upload WhatsApp 1、upload WhatsApp 2、has send 3、has read
    contentStringyescontent
    contentTypeIntegeryesType 0、normal text 1、pic 2、video 3、audio 4、file
    sendTimeStringyessend time
    originTypeIntegeryesorigin type 1、pc 2、app 3、web

When the data parameter messageStatus changes, the state is resynchronized, and everything else remains unchanged

  • content:

    AttributeTypeRequiredDescription
    filenameStringyesfile name
    urlStringyesfile url
    mimeTypeStringyesmime Type
    captionStringyesdescription
  • 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

    AttributeTypeRequiredDescription
    codeintyescode
    messageStringyesmessage
    dataStringyesdata
  • Response Example:

    {
      "code": 200,
      "message": "",
      "data": ""
    }
    

2.1 Callback validation

AttributeTypeRequiredDescription
tenantIdIntegeryestenant id
timestampLongyestimestamp
accessTokenStringyestoken
successDataListyessuccess callback ids
failDataListyeserror 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
AttributeTypeRequiredDescription
accessTokenStringyestoken
callBackUrlStringyescallback url(post)
tenantIdIntegeryestenant id
timestampLongyestimestamp
dataListyesdata
  • data
AttributeTypeRequiredDescription
idStringyesid (uuid)
friendWhatsIdStringyesfriend whatsapp
actionTypeIntegeryes1 join group 2 left group
createTimeStringyescurrent time
groupWhatsIdStringyesgroup whatsapp ID
groupLinkStringnogroup 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

AttributeTypeRequiredDescription
tenantIdIntegeryestenant id
timestampLongyestimestamp
tokenStringyestoken
successDataListyessuccess callback ids
failDataListyeserror 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

Last update:
Contributors: zhangzhuangzhuang,罗英杰