[英]Send message with cloud api whatsapp and google app script
Meta recently released the cloud api to send messages from Whatsapp business, but I can't send it from the google app script. Meta最近发布了云api来发送Whatsapp业务的消息,但是我无法从google app脚本发送。
I have this code, it runs fine... but it doesn't reach the user我有这段代码,它运行良好......但它没有到达用户
function SendToUser() {
var headers = {
'Authorization' : 'Bearer ACCESS_TOKEN',
'Content-Type': 'application/json'
};
var payload = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "PHONE_NUMBER",
"type": "text",
"text": { // the text object
"preview_url": false,
"body": "MESSAGE_CONTENT"
}
}
var options = {
method: "POST",
headers: headers,
payload: JSON.stringify(payload) // <--- Modified
}
let response = UrlFetchApp.fetch("https://graph.facebook.com/v13.0/FROM_PHONE_NUMBER_ID/messages", options);
Logger.log(response)
}
同样的事情发生在我身上,答案是正确的,但消息没有到达,只有 Hellow_Word 模板的例子在工作,其他的都没有。
See this project...看到这个项目...
https://github.com/pro-cms/whatsappcloud-php https://github.com/pro-cms/whatsappcloud-php
This work for me :)这对我有用:)
Have look at Heyooh , it's a Javascript Wrapper for WhatsApp Cloud API看看Heyooh ,它是 WhatsApp Cloud API 的 Javascript Wrapper
Installation安装
npm install heyooh
Here how sending to send messages;这里如何发送发送消息;
import WhatsApp from heyhooh
let messenger = new WhatsApp('TOKEN', phone_number_id='104xxxxxx')
messenger.send_template("hello_world", "255757xxxxxx")
dear friends of the stackoverflow community, The official documentation indicates that in order to send such messages, the conversation must be initiated by the user . stackoverflow社区的各位亲爱的朋友们,官方文档中指出,要发送这样的消息,对话必须由用户发起。 https://developers.facebook.com/docs/whatsapp/conversation-types
https://developers.facebook.com/docs/whatsapp/conversation-types
only approved templates can be sent as first message from whatsapp API account/phone number, try sending any message say 'Hi' back to api whatsapp account/phone number by the recipient to whom you were sending the message in the above script and then run the script, it runs for me by doing this.只有批准的模板才能作为第一条消息从 whatsapp API 帐户/电话号码发送,请尝试将任何消息发送回 api whatsapp 帐户/电话号码,由您在上述脚本中向其发送消息的收件人发送消息,然后运行脚本,它通过这样做为我运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.