1.我的模板已由Meta批准
1.我的令牌工作正常
1.语言代码已正确更新(en_US)
1.在Meta应用程序中正确设置权限
下面是我的Node Js代码,
app.post("/send-confirmation", async (req, res) => {
const { phoneNo, bookingId, name, tripType, origin, destination, bookedDate, bookedTime, carType, distance, estimate } = req.body;
const postData = JSON.stringify({
messaging_product: 'whatsapp',
recipient_type: 'individual',
to: [`91${phoneNo}`], // Phone number of the customer
type: 'template',
template: {
name: 'booking_confirmation',
language: {
code: 'en_US',
},
components: [
{
type: 'header',
parameters: [
{
type: 'image',
image: {
link: 'https://www.examle.com/logo-1.png',
},
},
],
},
{
type: 'body',
parameters: [
{
type: 'text',
text: `${bookingId}`,
},
{
type: 'text',
text: `${name}`,
},
{
type: 'text',
text: `${phoneNo}`,
},
{
type: 'text',
text: `${tripType}`,
},
{
type: 'text',
text: `${origin}`,
},
{
type: 'text',
text: `${destination}`,
},
{
type: 'text',
text: `${bookedDate} ${bookedTime}`,
},
{
type: 'text',
text: `${carType}`,
},
{
type: 'text',
text: `${distance}`,
},
{
type: 'text',
text: `${estimate}`,
},
],
}
],
},
});
try {
const response = await axios({
method: "POST",
url:
"https://graph.facebook.com/v17.0/117505268034839/messages",
data: postData,
headers: {
"Content-Type": "application/json",
'Authorization': `Bearer ${token}`
},
});
console.log(response.data); // or do something with the response data
res.send(response.data);
} catch (error) {
console.error(error);
res.send(error);
}
});
在请求发出后,我从Meta得到这个响应,
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "[\"917299568568\"]",
"wa_id": "917299568568"
}
],
"messages": [
{
"id": "wamid.HBgMOTE3Mjk5NTY4NTY4FQIAERgSM0MzMkE1NUVENTA2QTNCRUNBAA=="
}
]
}
但是,我不知道为什么信息没有被传递。请帮助我在这里错过什么
1条答案
按热度按时间cpjpxq1n1#
这很搞笑,但是当你在开发模式下使用API时,首先你必须向测试号发送消息,否则你将无法接收消息
查看此帖子以获得更好的解释