Integrate Whatsapp API with Node.js

  Рет қаралды 4,156

manfra․io

manfra․io

Күн бұрын

Пікірлер: 46
@manfraio
@manfraio 2 ай бұрын
The cost of using the official WhatsApp API is based on a conversation-based pricing model, where businesses pay per 24-hour conversation session with users. Prices range from approximately $0.005 to $0.07 for user-initiated conversations (session messages) and $0.02 to $0.14 for business-initiated ones (template messages), with the first 1,000 conversations per month being free.
@aneeshbakshi7200
@aneeshbakshi7200 2 ай бұрын
This is why I love your channel. You come up with the best tutorials.
@manfraio
@manfraio 2 ай бұрын
Thank you very much.🤜🏻🤛🏻
@alexdioliver
@alexdioliver 2 ай бұрын
Do not ever give up uploading new videos. You're a legend!
@manfraio
@manfraio 2 ай бұрын
Thank you my friend. 🤜🏻🤛🏻
@gianlucabredice8652
@gianlucabredice8652 23 күн бұрын
Thank you for this video. It's all I needed!
@tchisama
@tchisama 6 күн бұрын
i love u bro , i just was about to give up on wb i swear
@manfraio
@manfraio 6 күн бұрын
Glad I could help🤜🏻🤛🏻
@JigneshPatel-p8f
@JigneshPatel-p8f 18 күн бұрын
Very Nice tutorial!
@OnlyJavascript
@OnlyJavascript 2 ай бұрын
you are amazing bro. but post more tuts. i learned stirpe integration from you and completed a project too. thanks a lot.
@manfraio
@manfraio 2 ай бұрын
Thank you for the comment. Glad I could help.🤜🏻🤛🏻
@bernardtowindo1949
@bernardtowindo1949 Ай бұрын
Very helpful, thanks alot.
@dharsanr6504
@dharsanr6504 2 ай бұрын
Kindly post full stack project tutorials that will be awesome👍
@manfraio
@manfraio 2 ай бұрын
Yes, soon there will be full stack tutorials. Stay tuned my friend.🤜🏻🤛🏻
@smartdriver2990
@smartdriver2990 2 ай бұрын
Thanks for the useful content
@nobudev
@nobudev 2 ай бұрын
best release time 🥳
@noelrobin8674
@noelrobin8674 2 ай бұрын
Hi bro can u do a complete node js tutorial for an app like food delivery app but explained in way that beginners can understand
@manfraio
@manfraio 2 ай бұрын
Yes, soon we’re gonna upload entire project tutorials. Delivery app is one of them. Stay tuned!🤜🏻🤛🏻
@noelrobin8674
@noelrobin8674 2 ай бұрын
@@manfraio Thank you so much man looking forward to it !! 🔥🔥🔥
@innovateignite-753
@innovateignite-753 Ай бұрын
Hi! Thank you for video! very informative! What if we want to send verification code for the user? In such a case the user won't answer, we must send the code as a first message. Do you have any idea how to implement this?
@manfraio
@manfraio Ай бұрын
Thank you for the comment. You can create a template message with a variable that is gonna be the verification code. Just like on the video, instead of sending the user name on the variable , you send the code. Does that make sense?
@innovateignite-753
@innovateignite-753 Ай бұрын
@@manfraio Yes! Awesome! This way I don't need a Twillio in order to send just verification codes;) Thank you!
@innovateignite-753
@innovateignite-753 Ай бұрын
@@manfraio Other question, adding my own phone number to sending messages through Whatsapp, can I use the same number on my phone?
@manfraio
@manfraio Ай бұрын
The WhatsApp Business API requires you to register a dedicated WhatsApp Business number that is separate from your personal WhatsApp number.
@innovateignite-753
@innovateignite-753 Ай бұрын
@@manfraio I found the issue that whatsapp doesn't want to accept my templates with verification code. Do you have any template that they would accept?
@maheshkumar-dn6of
@maheshkumar-dn6of Ай бұрын
good, how can I send document(pdf) along text message
@manfraio
@manfraio Ай бұрын
Use the upload function to upload the pdf file to whatsapp server: async function uploadFile(filePath) { const data = new FormData() data.append('messaging_product', 'whatsapp') data.append('file', fs.createReadStream(filePath) data.append('type', 'application/pdf') const response = await axios({ url: 'graph.facebook.com/v20.0/phone_number_id/media', method: 'post', headers: { 'Authorization': `Bearer ${process.env.WHATSAPP_TOKEN}` }, data: data }) return response.data.id } Then call the uploadFile function and send a message along with the file: async function sendPDFFile() { const pdfFileId = await uploadFile(filePath) const response = await axios({ url: 'graph.facebook.com/v20.0/phone_number_id/messages', method: 'post', headers: { 'Authorization': `Bearer ${process.env.WHATSAPP_TOKEN}`, 'Content-Type': 'application/json' }, data: JSON.stringify({ messaging_product: 'whatsapp', to: 'phone_number', type: 'document', document: { id: pdfFileId, caption: 'This is message', filename: 'any_filename' } }) }) console.log(response.data) }
@Ola_Editzz
@Ola_Editzz 12 күн бұрын
you didn't explain on how to receive a text from the bot ?
@manfraio
@manfraio 12 күн бұрын
That’s a little more complex cause it envolves webhooks. I’ll create another video for that.
@Ola_Editzz
@Ola_Editzz 10 күн бұрын
@@manfraio thank you for the response, please is there any way i can send a button menu to a user with whatsapp api
@09avishkargaikwad71
@09avishkargaikwad71 Ай бұрын
I'm not able to select the test phone numbers. In your case the test phone is automatically generated but that's not same in my case. Can you provide any guidance?
@manfraio
@manfraio Ай бұрын
You mean the test number that whatsapp generated for you to use to send messages or the phone number you add, to send to that number?
@maged_sar7an
@maged_sar7an Ай бұрын
​@manfraio All of them please 😢
@SathishM-n8i
@SathishM-n8i Ай бұрын
can we create a chatbot from Whatsapp API with Node.js ?
@manfraio
@manfraio Ай бұрын
Yes. You would need to create a webhook on your server to listen for incoming messages, and configure this webhook on your whatsapp business platform: // Webhook to receive messages from WhatsApp app.post('/webhook', (req, res) => { const webhookEvent = req.body; // Check if this is a message event if (webhookEvent.entry && webhookEvent.entry[0].changes && webhookEvent.entry[0].changes[0].value.messages) { const messageEvent = webhookEvent.entry[0].changes[0].value.messages[0]; const from = messageEvent.from; // The user's phone number const messageText = messageEvent.text.body; // The message content // Chatbot logic to respond to the message let responseMessage; // Basic chatbot responses (you can expand this logic) if (messageText.toLowerCase().includes('hello')) { responseMessage = 'Hello! How can I assist you today?'; } else if (messageText.toLowerCase().includes('price')) { responseMessage = 'Our products range from $10 to $100. How can I help with pricing?'; } else if (messageText.toLowerCase().includes('bye')) { responseMessage = 'Goodbye! Have a great day!'; } else { responseMessage = 'Sorry, I did not understand that. Can you please rephrase?'; } // Send the response back to the user sendMessage(from, responseMessage); } // Send a 200 OK response back to WhatsApp res.sendStatus(200); }); // Verification route to verify the webhook with WhatsApp app.get('/webhook', (req, res) => { const verifyToken = process.env.VERIFY_TOKEN || 'your_verify_token'; const mode = req.query['hub.mode']; const token = req.query['hub.verify_token']; const challenge = req.query['hub.challenge']; // Validate the webhook token if (mode && token === verifyToken) { console.log('Webhook Verified'); res.status(200).send(challenge); } else { res.sendStatus(403); } });
@insidedocumentary3162
@insidedocumentary3162 2 ай бұрын
Bro how can i add multiple number you didn't tell that
@manfraio
@manfraio 2 ай бұрын
You have to loop inside an array of numbers. Till today the api only allow to send to one number.
@manfraio
@manfraio 2 ай бұрын
Here’s an example: const phoneNumbers = ['1234567890', '0987654321', '1123456789']; // Message you want to send const messageText = 'Hello from WhatsApp via Node.js!'; // Loop through each phone number and send a message phoneNumbers.forEach(async (phoneNumber) => { try { // Send the message const response = await axios.post( apiURL, { messaging_product: 'whatsapp', to: phoneNumber, type: 'text', text: { body: messageText } }, { headers: { 'Authorization': `Bearer ${accessToken}`, 'Content-Type': 'application/json' } } ); console.log(`Message sent to ${phoneNumber}:`, response.data); } catch (error) { console.error(`Failed to send message to ${phoneNumber}:`, error.response ? error.response.data : error.message); } });
@insidedocumentary3162
@insidedocumentary3162 2 ай бұрын
@@manfraio Bother For Production level I want to send message on any Whatsapp like through my postmen, i take that number through user and send messages to that number is it possible?
@manfraio
@manfraio 2 ай бұрын
@insidedocumentary3162 yes, but you cannot send any message. You have to send an template
@insidedocumentary3162
@insidedocumentary3162 2 ай бұрын
@@manfraio Yes i should send Template now is there any setting i have to do on face portal, 2nd the code you provide is enough to send Template message to anyone without adding there number in Facebook Developer Test Number list
How to integrate PayPal API with Node.js
51:55
manfra․io
Рет қаралды 10 М.
Stripe Checkout Subscriptions + Webhooks with Node.js
1:04:13
manfra․io
Рет қаралды 6 М.
CAN YOU DO THIS ?
00:23
STORROR
Рет қаралды 48 МЛН
龟兔赛跑:好可爱的小乌龟#short #angel #clown
01:00
Super Beauty team
Рет қаралды 130 МЛН
PIZZA or CHICKEN // Left or Right Challenge
00:18
Hungry FAM
Рет қаралды 11 МЛН
My MEAN sister annoys me! 😡 Use this gadget #hack
00:24
JOON
Рет қаралды 2,8 МЛН
How to Use WhatsApp Business Cloud API | Complete WhatsApp Cloud API Setup 2024
17:06
Wp hacks4u-WordPress Tutorials for Beginners
Рет қаралды 8 М.
Building End-to-End Experiences with the WhatsApp Business Platform
48:05
Sending emails with Node.js using Nodemailer
25:38
manfra․io
Рет қаралды 1 М.
How to Build a WhatsApp AI Chatbot in Minutes Using Flowise
19:55
Leon van Zyl
Рет қаралды 16 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 657 М.
Node.js Rest API to send and receive messagem from WhatsApp - PART 1
22:45
CAN YOU DO THIS ?
00:23
STORROR
Рет қаралды 48 МЛН