I'm using cloud whatsapp api to build a bot. I have some list messages and I'm trying to distinguish bewteen each one.. for example I'm sending a message list to select employee
then I send a message list to select a time
if the user select each time, select employee and not select date, I don't have a way to know what the list he selected. this is the payload of the time selected
{
msg: '{"from":"XXXX","id":"XXXXXX","timestamp":"1660854604","type":"list_reply","data":{"id":"12:00","title":"12:00","context":{"from":"XXXXX","id":XXXXXXX"}}}'
payload of select employee
{
msg: '{"from":"xxxxx","id":"xxxxx","timestamp":"1660854672","type":"list_reply","data":{"id":"xxxxx","title":"Yativ","context":{"from":"972524741182","id":"xxxxx"}}}'
}
it looks like the same payload, just the data is different. I'm looking for any id of list to know this response is from the list of select employee or select time..
Payload for a message has message object and it has message-id ( id
), that is inside entry[0].changes[0].value.messages[0].id
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "WHATSAPP_BUSINESS_ACCOUNT_ID",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
...
"messages": [
{
"id": "wamid.ID", // <===== message id
...
}
]
},
"field": "messages"
}
]
}
]
}
See the Example Payload
You have to store (in the database) the message-id ( id
) from the message send API/endpoint, whenever you send a message to the user,
(this is a response from send message API/endpoint)
{
"messaging_product": "whatsapp",
"contacts": [{
"input": "PHONE_NUMBER",
"wa_id": "WHATSAPP_ID",
}]
"messages": [{
"id": "wamid.ID" // <==== store this in your database
}]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.