Giter VIP home page Giter VIP logo

whatsapp-api-examples's Introduction

WhatsApp Business Platform and Cloud API Examples

This repository is a hub for examples of how developers can use Cloud API, hosted by Meta, on the WhatsApp Business Platform.

Directory

  1. message-templates-js - A WhatsApp application that demonstrates creating and using message templates, as described in this blog post.

    Note: there are two app versions in this subdirectory - one is a boilerplate code for the application, and one is a complete version of the app.

  2. basic-webhook-js - basic WhatsApp webhook app written using Node.js used in this blog post.

  3. media-messages-js - Demo of how to use WhatsApp Business Platform with media messages, as described in this blog post.

    Note: there are two app versions in this subdirectory - one is a boilerplate code for the application, and one is a complete version of the app.

  4. send-messages-movie-ticket-app-js - a sample app built with Node.js and WhatsApp Business Platform.

  5. send-messages-flight-app-python - a sample app build with Python and WhatsApp Business Platform.

  6. send-messages-ecommerce-app-java - a sample app build with Java and WhatsApp Business Platform.

  7. template-for-education-js - A template application that demonstrates sending educational course offerings, written in Node.js.

  8. template-for-ecommerce-js - a template application that demonstrates a communication with customers in a simplified ecommerce usecase, written in Node.JS.

  9. signature-validation-with-webhooks-payloads - a sample app that demonstrates how to validate signature for the WhatsApp Business Platform Webhooks' Payloads.

License

whatsapp-api-examples is Meta Platform Policy licensed, as found in the LICENSE file.

whatsapp-api-examples's People

Contributors

dmitryvinn avatar dmitryvinn-fb avatar rashedtalukder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

whatsapp-api-examples's Issues

Whatsapp API messages templates from those examples: where ?

When I finally managed to create my first WhatsAppp application in this obstacles course that are the Meta backoffice pages (BTW, I have never seen such "thing" in terms of ergonomics that would make Steve Jobs turn in his grave, that is to say dispersing in myriads of different places on each page links to same pages and functionalities), I got only the "Hello World" template.

Nowhere in the documentation I was able to find where and how to get the others mentioned in those examples.

Delete a template

I'm trying delete a template following the example below:

exports.deleteMessageTemplate = async (req, res) => {
  request.delete(
    {
      url: `https://graph.facebook.com/v13.0/${process.env.META_BUSINESS_ID}/message_templates`,
      headers: {
        Authorization: `Bearer ${process.env.META_AUTH_TOKEN}`,
        "content-type": "application/json",
      },
      body: JSON.stringify({
        name: req.body.name,
      }),
    },
    function (err, resp, body) {
      if (err) {
        console.log("Error!");
      } else {
        res.json(JSON.parse(body));
      }
    }
  );
};

My code:

  #deleteTemplate(data: any) {
    const config: AxiosRequestConfig = {
      method: 'post',
      url: `https://graph.facebook.com/${this._version}/${envs.WHATSAPP_BUSINESS_SECRET}/message_templates`,
      headers: {
        Authorization: `Bearer ${this._token}`,
        'Content-Type': 'application/json',
      },
      data,
    }

    return axios(config)
  }
  
   async DEL(req: Request, res: Response) {
    const body = req.body

    try {
      await this.#deleteTemplate(body)

      res.status(200).send({
        title: 'Template excluído com sucesso!',
        desc: 'A alteração pode demorar algum tempo para ser confirmado.',
      })
    } catch (error) {
      if (error instanceof AxiosError) {
        const errorData = error.response?.data

        if (errorData.error.code === 100) {
          res.status(401).send(errorData.error.message)

          return
        }

        console.log('🚀 ~ Template ~ DEL ~ tes:', errorData)

        return
      }
      console.log(error)
    }
  }
  
  clientRoute.delete(
  '/client/template',
  async (req, res) => await template.DEL(req, res),
)

body:

{
    "name": "test"
}

I'm try with id as well, but nothing, always return an error, similar this:

(#100) The parameter language is required.

I've been add all parameters that it say and nothing.

Error on upload media

I'm trying upload a image o whatsapp server but return an error:

      error: {
        message: '(#100) Param file must be a file with one of the following types: audio/aac, audio/mp4, audio/mpeg, audio/amr, audio/ogg, audio/opus, application/vnd.ms-powerpoint, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/pdf, text/plain, application/vnd.ms-excel, image/jpeg, image/png, image/webp, video/mp4, video/3gpp.',
        type: 'OAuthException',
        code: 100,
        fbtrace_id: 'AM2yIhYd_KoSd5dQerkfErV'
      }

code:

const config: AxiosRequestConfig = {
      method: 'post',
      url: `https://graph.facebook.com/${this._version}/${envs.BOT_PHONE_ID}/media`,
      headers: {
        Authorization: `Bearer ${envs.WHATSAPP_TOKEN}`,
        'content-type': 'multipart/form-data',
      },
      data: {
        file: {
          value: fs.createReadStream(file.path),
          options: {
            filename: file.filename,
            contentType: file.mimetype,
          },
        },
        type: file.mimetype,
        messaging_product: 'whatsapp',
      },
    }

    const { data } = await axios(config)

Profile and QR code issue

can u please provide python method to get and update WhatsApp api business profile and please also qr code sending option method in python.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.