Webhook
To receive a webhook message you need to configure the webhook url on each devices configuration. Go to Devices -> configuration and add webhook url.
What Can I Receive ?
- Response JSON General Text Message
- Response JSON Document Type Message
- Response JSON Image Type Message
- Response JSON Contact Type Message
- Response JSON Audo Type Message
- Response JSON Replying Message
- Reply with Single Message
- Reply With Image Message
- Reply With File Message
- Reply With Button Message (Deprecated)
- Reply With Template Message (Deprecated)
- Reply With List Message (Deprecated)
- Reply With Reaction
- Reply With Multiple Message
This i give you and examples format for handle your webhook:
Examples Response JSON
General Text Message
{
"message": "help",
"from": "62856123456",
"timestamp": 1581651709,
"message_id": "3219EDE2131",
"from_user": {
"name": "Contact Name",
"jid": "Unique WA ID"
},
"is_forwarded": false,
"is_broadcast": false
}
Document Type Message
This message type only work with Startup package
{
"type": "documentMessage",
"file": {
"url": "https://whatspie.is3.cloudhost.id/whatspie/messages/2022-10-05/2313213F3213.pdf",
"caption": null,
"fileName": "file_name.pdf"
},
"from": "62856123456",
"participant": null,
"timestamp": 1664933170,
"message_id": "2313213F3213",
"from_user": {
"name": "Sender Name",
"jid": "62856123456@s.whatsapp.net"
},
"is_forwared": false,
"is_broadcast": false
}
Image Type Message
This message type only work with Startup package
{
"type": "imageMessage",
"file": {
"url": "https://whatspie.is3.cloudhost.id/whatspie/messages/2022-10-05/3EB0237E918896635AD332133.jpeg",
"caption": "hi gan",
"fileName": null
},
"from": "628561234456",
"participant": null,
"timestamp": 1664932915,
"message_id": "3EB0237E918896635AD3",
"from_user": {
"name": "Sender Name",
"jid": "628561234456@s.whatsapp.net"
},
"is_forwared": false,
"is_broadcast": false
}
Contact Type Message
This message type only work with Startup package
{
"type": "contactMessage",
"contacts": [
{
"displayName": "Contact Name",
"vcard": "BEGIN:VCARD\nVERSION:3.0\nN:;A77;;;\nFN:A77\nTEL;type=CELL;waid=6285846255569:+62 858-4625-5569\nEND:VCARD"
}
],
"from": "628561234456",
"participant": null,
"timestamp": 1664933238,
"message_id": "3EB0E9CAAA9BBC8C1081",
"from_user": {
"name": "Sender Name",
"jid": "628561234456@s.whatsapp.net"
},
"is_forwared": false,
"is_broadcast": false
}
Audio Type Message
This message type only work with Startup package
{
"type": "audioMessage",
"file": {
"url": "https://whatspie.is3.cloudhost.id/whatspie/messages/2022-10-05/3EB0E9CAAA9BBC8C1081.oga",
"caption": null,
"fileName": null,
"seconds": 3
},
"from": "628561234456",
"participant": null,
"timestamp": 1664932741,
"message_id": "3EB0E9CAAA9BBC8C1081",
"from_user": {
"name": "Sender Name",
"jid": "628561234456@s.whatsapp.net"
},
"is_forwared": false,
"is_broadcast": false
}
Replying Message Response
To replying using webhook, you need to return valid json content with following format, other wise whatspie will not replying back the message.
Single Message
to reply this message you need to return response will following JSON response:
{
"type": "chat",
"body": "This is reply\n",
"simulation": true
}
Reply with Image message
to reply this message you need to return response will following JSON response:
{
"type": "chat",
"body": "Hello",
"params": {
"image": {
"url": "https://images.unsplash.com/photo-1653764982079-c7c5e4fd682a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80"
},
"caption": "Lovely Photo"
}
}
Reply with File message
to reply this message you need to return response will following JSON response:
{
"type": "chat",
"body": "Hello",
"params": {
"document": {
"url": "http://www.africau.edu/images/default/sample.pdf"
},
"fileName": "file.pdf",
"mimeType": "application/pdf"
}
}
Reply with Button message (Deprecated)
to reply this message you need to return response will following JSON response:
{
"type": "chat",
"body": "Hello",
"params": {
"text": "This is button message from Whatspie!",
"footer": "This is footer",
"buttons": [
{
"buttonId": "id1",
"buttonText": {
"displayText": "Button 1"
},
"type": 1
}
]
}
}
Reply with Template message (Deprecated)
to reply this message you need to return response will following JSON response:
{
"type": "chat",
"body": "Hello",
"params": {
"text": "This is template message from Whatspie!",
"footer": "This is footer",
"image": {
"url": "https://images.unsplash.com/photo-1653764982079-c7c5e4fd682a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80"
},
"templateButtons": [
{
"index": 1,
"urlButton": {
"displayText": "Visit Whatspie",
"url": "https://whatspie.com"
}
},
{
"index": 2,
"callButton": {
"displayText": "Call Button",
"phoneNumber": "+62 815-6365-5211"
}
},
{
"index": 3,
"quickReplyButton": {
"displayText": "Quick Reply Button",
"id": "id-like-buttons-message"
}
}
]
}
}
Reply with List message (Deprecated)
to reply this message you need to return response will following JSON response:
{
"type": "chat",
"body": "Hello",
"params": {
"text": "This is a list",
"footer": "This is footer",
"title": "This is footer title",
"buttonText": "Required, text on the button to view the list",
"sections": [
{
"title": "Section 1",
"rows": [
{
"title": "Option 1",
"rowId": "option1"
},
{
"title": "Option 2",
"rowId": "option2"
}
]
}
]
}
}
Reply with Reaction message
to reply this message you need to return response will following JSON response:
{
"type" : "reaction",
"body" : "🤣"
}
Reply with Multiple message
to reply this message you need to return response will following JSON response:
[
{
"type": "chat",
"body": "First message",
"simulation": true
},
{
"type": "chat",
"body": "Second Message",
"simulation": true
}
]