I have a nodejs bot and a method which helps me send client a request for their location using a special Meta Whatsapp body as prescribed in the section Location Request Messages of Sending Interactive Messages Doc:
Doc prescription below:
{
"type": "location_request_message",
"body": {
"type": "text",
"text": "<TEXT>"
},
"action": {
"name": "send_location"
}
}
Wrapping component of the code above according to the doc (doc says you have to add the above code inside of the interactive property of the blow code):
{
"recipient_type": "individual",
"to" : "whatsapp-id", // WhatsApp ID of your recipient
"type": "interactive",
"interactive":{
// Your interactive object
}
}
My own code is below (I combined the 2 above codes in one as prescribed by the doc):
const body = {
recipient_type: "individual",
to: "mobile_number", // WhatsApp ID of your recipient
type: "interactive",
interactive:{
// Your interactive object
type: "location_request_message",
body: {
type: "text",
text: "Finally"
// text: "Good day"
},
action: {
name: "send_location"
}
}
}
And i send it with axios with my promise:
return new Promise((next) => {
var headers = {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
};
AxiosService.post(
`https://graph.facebook.com/${VERSION}/${JC_PHONE_ID}/messages`,
body,
headers
)
.then((response) => {
// console.log("THIS RESPONSE IS REALLY BIG: ", response)
if (response.status == 200) {
console.log(response.status)
next({ success: true, status: 200 });
} else {
console.log(response.status)
console.log("Heehehehe....")
next({ success: false, status: 400 });
}
})
.catch((err) => {
next({ success: false, status: 400 });
});
});
Finally sending a request for it using my webhook link:
At the end i get a 400 error:
I am pretty sure it is because facebook does not accept the way i set the body.
Can anyone help me on how to set the above json body properly?