简体   繁体   English

使用云 api whatsapp 和 google app 脚本发送消息

[英]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.

相关问题 如何使用 Whatsapp Cloud API 发送短信 - How to send a text message with Whatsapp Cloud API 在whatsapp业务云api中向多个收件人发送消息 - Send a message to multiple recipients in whatsapp business cloud api 如何在whatsapp cloud api中发送组件? - How to send the components in whatsapp cloud api? 如何从whatsapp cloud api中的消息ID获取消息对象? - how to get message object from message id in whatsapp cloud api? Laravel 向 WhatsApp 发送消息 - Laravel send message to WhatsApp whatsapp 云 api 模板 object 问题发送自 postman - whatsapp cloud api template object issue to send from postman 当我们通过 WhatsApp 发送图像时,如何在 WhatsApp Business Cloud API 中获取图像的 URL - How to get the URL of an image in WhatsApp Business Cloud API, while we send an image through WhatsApp Kraken.com API:在Google App脚本中生成消息签名 - Kraken.com API: Generate the message signature in Google App Script Firebase 通过 POST 请求向 Android 应用主题发送云消息 - Google Oauth Playground 访问令牌到期 - Firebase Send Cloud Message to Android App Topics via POST Request - Google Oauth Playground Access Token Expiration 回复whatsapp上的具体whatsapp消息 api - Reply to specific whatsapp message on whatsapp api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM