Giter VIP home page Giter VIP logo

whatsapp-api-examples's Issues

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.

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)

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.

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.

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.