Custom Bot Integration with vCX for HITL
Follow the steps to set up WhatsApp API using the manual method or embedded signup
A webhook to receive incoming messages
Incoming Message format
Below is the format of incoming messages payload as received from META webhook and will be forwarded to your Bot webhook
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "213886151817424"xxxxxxxxxx",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "918431611935"xxxxxxxxxx",
"phone_number_id": "292712607248981"xxxxxxxxxx"
},
"contacts": [
{
"profile": {
"name": "LijoSanjeev Mathew"Reddy"
},
"wa_id": "919741391700"xxxxxxxxxx"
}
],
"messages": [
{
"from": "919741391700"xxxxxxxxxx",
"id": "wamid.HBgMOTE5NzQxMzkxNzAwFQIAEhgUM0Y2OTU4Qzc0OEYyMkMzQ0NCOEIA",
"timestamp": "1733564481",
"text": {
"body": "hi"
},
"type": "text"
}
]
},
"field": "messages"
}
]
}
]
}
Outgoing Messages to the user
format to send data to META using vCX
curl --location 'https://api.versal.one/<client-id>' \
--header 'Authorization: Bearer <client-token>' \
--header 'Content-Type: application/json' \
--data '{
"purpose": "sendmessage",
"message_data": {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": <recepient>,
"type": "text",
"text": {
"body": <Message or response from Bot>
}
}
}'
Outgoing messages to vCX
format to send data to vCX as a bot response
to be sent to http://webhook.versal.one/<client-id>
{
"responsefrom": "Bot",
"conversation": {
"id": "0470d58f-ad45-4d16-b229-76476e598fed",
"type": "text",
"channel": "channel",
"direction": "outgoing",
"payload": {
"type": "text",
"text": "Hello! I am Bot, your virtual assistant",
"markdown": true
},
"preview": "Hello! I am Bot, your virtual assistant",
"incomingEventId": "48621030-b469-420e-b827-9b9b293ba312"
},
"phonenumber": "919741391700"xxxxxxxxxx"
}