whatsapp bot without third party like Twilio or web driver

Question:

I’m planning to integrate a simple chatbot to WhatsApp which I build using fastapi and python. My goal is to send/receive messages to users using the WhatsApp Api. I want to know how can I connect WhatsApp Api without using a web driver or third party?

Asked By: new_dev

||

Answers:

It is possible, but you need to gain access to the WhatsApp business platform. Once you have access, you can use the WhatsApp Cloud API which is a HTTP API. Using webhooks you can receive conversations.

For example, to send a message:

curl -i -X POST 
  https://graph.facebook.com/v14.0/FROM_PHONE_NUMBER_ID/messages 
  -H 'Authorization: Bearer ACCESS_TOKEN' 
  -H 'Content-Type: application/json' 
  -d '{ "messaging_product": "whatsapp", "to": "TO_PHONE_NUMBER", "type": "template", "template": { "name": "hello_world", "language": { "code": "en_US" } } }'

However note that at this time access is limited, e.g. they do not allow application development for other clients. And it is not free after the first 1000 conversations per month, they charge for each conversation.

Answered By: Geert
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.