Whatsapp 云消息未送达

问题描述 投票:0回答:1
  1. 我的模板已获得 Meta 批准
  2. 我的令牌工作正常
  3. 语言代码已正确更新(en_US)
  4. 元应用程序中的权限均已正确设置

下面是我的 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=="
        }
    ]
}

但是,我不确定为什么消息没有被传递。请帮助我在这里缺少什么

node.js facebook-graph-api whatsapp-cloud-api
1个回答
0
投票

这很搞笑,但是当你在开发模式下使用api时,你首先要向测试号发送消息,否则你将无法接收消息

查看此帖子以获得更好的解释

© www.soinside.com 2019 - 2024. All rights reserved.