将 WhatsApp 流作为消息模板发送时出错

问题描述 投票:0回答:1
//rest of code


//flow
      let message= {
        name: "lzgoflow",
        language: "en_US",
        category: "MARKETING",
        components: [
          {
            type: "body",
            text: "hello there",
          },
          {
            type: "BUTTONS",
            buttons: [
              {
                type: "FLOW",
                text: "lzgo",
                flow_id: 937561724890552,
                navigate_screen: "lzgo flow",
                flow_action: "navigate",
              },
            ],
          },
        ],
      };

      axios({
        method: "POST",
        url:
          "https://graph.facebook.com/v12.0/" +
          phone_number_id +
          "/messages?access_token=" +
          token,
        data: message,
        headers: { "Content-Type": "application/json" },
      })
        .then((response) => {
          console.log("Message sent successfully:", response.data);
        })
        .catch((error) => {
          console.error("Error sending message:", error.message);
        });
    }
    res.sendStatus(200);
  } else {
    res.sendStatus(404);
  }
});

这是我的 node.js 代码,请求发送 WhatsApp 流消息,但每次运行它时都会出现此错误

Error sending message: Request failed with status code 400 

我检查了所有详细信息(流 ID、名称和语言代码),它们都是相同的,但它仍然给我这个错误。

whatsapp whatsapp-cloud-api whatsapp-flows
1个回答
0
投票

我认为您混合了文档中提到的两个 API 调用。 似乎您使用的消息变量正在为创建模板构建请求正文 但您发送的 Post call URL 用于发送模板,如示例 here.

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