How To Connect OpenAI To WhatsApp (Python Tutorial)
Vložit
- čas přidán 1. 08. 2024
- Want to get started with freelancing? Let me help: www.datalumina.com/data-freel...
Need help with a project? Work with me: www.datalumina.com/consulting
🔗 Links in this video
github.com/daveebbelaar/pytho...
⏱️ Timestamps
00:00 Introduction
00:57 Meta Prerequisites
01:22 Create Your Meta Business App
02:25 Add WhatsApp to the App
02:41 Select Phone Numbers
04:37 Send Messages with the API
11:57 Configure Webhooks to Receive Messages
20:40 Understanding Webhook Security
23:14 Learn about the API and Build Your App
24:11 Integrate AI into the Application
28:33 Integrate Your Own AI Functions
👋🏻 About Me
Hey there! I'm Dave, an AI Engineer and the founder of Datalumina, where our mission is to facilitate entrepreneurial and technological proficiency in professionals and businesses. Through my videos here on this channel, my posts on LinkedIn, and courses on Skool, I share practical strategies and tools to navigate the complexities of data, artificial intelligence, and entrepreneurship.
🛠️ My Development Workflow
• My Development Workflo...
✔️ My Project Management Tool
clickup.pxf.io/datalumina
🎓 Our Training Programs
www.skool.com/data-alchemy
www.skool.com/data-freelancer
🔗 Let's Connect
/ daveebbelaar
/ daveebbelaar
📥 Datalumina's Newsletter
www.datalumina.com/newsletter
📊 How I'm using data to track my health
join.whoop.com/datalumina
#ai #whatsapp #bot
📌 Video Description
In this video, Dave shares how he set up a WhatsApp AI bot using only Python, and he did it for free. He carefully shows you through a repository with all the code and instructions you need to do this on your own devices. Dave makes sure you know the basics, like understanding Python and setting things up in VS Code, so you're ready to make your own WhatsApp AI bot. He points out that you should start with a Meta developer account and make a business app. This is key for linking WhatsApp with the bot.
Dave goes into the technical steps of getting the WhatsApp business app and API ready. This includes getting a test phone number and adding it to Meta's developer portal. He teaches how to use the API to send messages and the important part of setting up environment variables for the bot to work smoothly. Dave shows you how to send a "Hello World" test message and why replying to this message is important for more custom messaging. This part is essential to understand how the bot works with WhatsApp's messaging service.
Next, Dave talks about webhooks, which let the bot receive and answer messages on its own. This part can be tough but also rewarding. It's about setting up webhooks to act when messages come in. Dave takes you through how to set up and protect webhooks, so you can get your applications to listen for messages well. This is important if you want to make interactive and quick-to-respond WhatsApp bots.
Towards the end of the video, Dave looks at adding AI to the WhatsApp bot. This turns it from a simple auto-responder into a smart AI assistant that can handle complex questions. He shows how to use OpenAI services to make the bot better, giving you a peek at what AI can do in messaging apps. Dave finishes by encouraging you to look into more API features and think about the security of webhook interactions. This guide isn't just a tutorial; it's an invite to dive into the exciting mix of AI and messaging apps. It gives you the tools and info to create your own advanced WhatsApp AI bots.
🔐 Copy my AI tools & workflows: bit.ly/data-alchemy
💰 Kick-start your data freelance career: www.datalumina.com/data-freelancer
Where is the link for the github repo
github.com/daveebbelaar/python-whatsapp-bot
Brilliant!!! thanks!
@@traggerosbourne6877 At least say "please"...
@@daveebbelaar Thanks alot indeed beyond words
You sir, have just earned yourself a new subscriber! Thank you so much for this tutorial, the documentation was a bit tricky but you killed it! Hope to see more from you in future, cheers Dave.
Thank you for this excellent step-by-step tutorial, was so much required. Keep going strong 👍🙏
Awesome, I don't have any idea either Python or programming in general, but this guy explain in such great way that I will try to do it.
thanks Dave, really appreciate the trouble you went through to make this accessible to all of us. Great job! 🙏
You're welcome!
I am really impressed the great job you made Dave. Thanks to you absolutely. You win another subscriber. I bought a course on udemy on the topic and is not really good explained as you did here. Thanks to you for share your knowledge and keep the good work. Blessings!
Thanks so much for this helpful repo and video on that topic!
i have really benefited from your video. thank you so much.
00:02 Build a free AI WhatsApp bot with Python
02:15 Setting up the initial bot for AI WhatsApp Chatbot
06:59 Create a longer-lasting token for WhatsApp API setup
09:22 Configuring connection and sending custom messages on AI WhatsApp chatbots.
14:02 Enrock tool helps bypass local host for testing purposes.
16:14 Integrating with WhatsApp involves setting up a webhook and verification token.
20:42 Understanding web hook security and its implementation
22:47 Learn how to sell and monetize by building WhatsApp AI Bots as a freelancer
26:56 Build a WhatsApp AI bot to process and respond to messages.
28:58 Configuring Flask app for WhatsApp utilities
Really looking forward to the next video (hoping it is very soon). I would like to see how you convert this into a Production environment and setting it up to receive unverified numbers. This setup is very clean and I like that you don't have to botch together the use of other services in order to get it working like I have seen with other tutorials.
Have you made it run in your side?
@@sealandland3959 have you ?
Thanks a lot! Great tutorial!
Thank you very much . The best video on using whatsapp api . Thank you again
This is GOLD!
What a nice video. Thank you! :)
Brilliant content :)
Great video! Learnt a lot
Thanks for share your skills with the community. Great tutorial !
Very very cool! Thank you
COOL BRO. Nice tut tut.
thanks dave, outstanding project
Glad you enjoyed it
Great video❤❤
Thanks BRO it's amazing CONTENT I love you
Thanks for the useful video. Was able to completely follow and set things up quite quickly.
Great to hear!
i got stuck on this ! any solutions ?
401
{'error': {'message': 'Invalid OAuth access token - Cannot parse access token', 'type': 'OAuthException', 'code': 190, 'fbtrace_id': '******'}}
i already check my token and it is correct , what should i do ?
Thank you for this dude
Happy to help!
Hi, I could not see the link for the video that you mention at 25:45
sir , my webhook is working and credintials are verified on local but on server its not working
Best WhatsApp video out there
Thank you 🙏
Thank you for making this accessible.
So, We can't make it enter Groups? Can't do stickerize things mostly, etc. ?
HI Dave, Great content! happy for you
Amazing!
Thank you i needed a detailed tutorial like this one. Just to know, do you hace any code example or tutorial tu use OpenAI and google calendar to make apointments via agents/function calling to add to this tutorial?
i am getting the error Signature verification failed!
I alreqady reloaded the tokenm, created and tested a new ngrock domain many times but it doesnt work. any tips here?
it works perfectly but when i ask questions related to the pdf file, the first answer is normal but the GENERATED message says something like it doesn't information related to the airbnb and stuff although in the IDE it answered correctly, anyone can help?
This is great stuff 😊 subscribed! Instead of uploading a pdf file for the gpt assistant, can I use a database?
hi is there any way that i can change the image thumbnail when sharing a link? i wanna make my link personalized
Man you are awesome, never seen a tutorial like this. How do I buy you coffee?
That means a lot to me - thank you! CZcams actually has a feature for this where you can click "thanks" just underneath this video (same row as the like button).
I have yet to see any videos on chatbot and if the customer needs live agent it will transfer. Can you help me with that or point me to some kind of library or services. Thanks
Followed every step, but it keeps giving me the 403 error. any idea on how to resolve this? Read a lot on Stack overflow, debugged, but seems that I am really missing a step here ;-)
Hi @dave Ebbelaar goede video. Ik vroeg me af hoe het zit met memory in de chat zelf
Hey Dave, Thanks for tutorial, One more question, can we use our own api (based on llm which can answer question on my data ) and then use it to send answer to the questions asked on this whatsapp bot?
great vid
Great tutorial, brother!! Thank you.
How do I get this to work for chatgpt vision functionality? For example I would like a WhatsApp user to be able to send an image on WhatsApp to the gpt, and the gpt responds according to whatever is in the image
I'm having an issue creating the Meta Business Account. I already have one linked to my Facebook profile but the developers page still asks me to create one in order to complete the onboarding process.
Is there any request limitation while using meta APIs?
Great tutorials! Is there any way that I can add users using API calls and not manually through meta developer app portal?
Make another video on how to finetune this on our own dataset.
Facing an issue.
Each time I change the access token On sending a message I get the error - Recipient not allowed in the list for which gets resolved on the recipient_waid variable name and running again. Can you something as why it might be happening?
I configured the webhook but when I send messages to the test number nothing happens
Just a quick one, am new to dev, how can I make the menu within the message templates to engage with a client when they send a message. E.g Main menu > Customer service > chat with an agent
Do we necessarily need a real business account ? I don't have a business email ... What can I do?
can we integrate this on websites Dave?
But what if i want all users to contact my bot not only the number we did setup ?
If you are using VSCode you can use the "ports" feature which takes about 30 seconds. Instead of all the hasle of ngrok. Make sure you set the port to public
Hey Can anyone tell me how I can add buttons tooo ?
Thanks, Dave! What kind of data can be used apart from a PDF? A screenshot or the information from a URL for example?
Because this is a custom setup, you can literally use any data you can imagine. You would just have to create a separate service for that.
Awesome!!
Can you add more videos for your Alchemy classroom?
Excellent video!.....i have followed the same as u shown in the video but facing this error (The callback URL or verify token couldn't be validated.) while configuring webhook can u please help me through this?
Hi Dave, is it possible to find a. Easier way??
Since Whatsapp group api is depreciated is there any way to make a group and add 2 users and have the bot facilitate the conversation? Does anyone have any information on this. Any help would be greatly appreciated :)
i had issues with the bearer token, please assist..
Can we make it multilingual?
thank u
Hi,
i get this error while trying to add callback url . Do you have any idea? Thanks :
"message": "Invalid signature"
I am getting this error aswell did you figure it out?
I clone the repo and everything and i still couldn't pass the first step because of error 400 and showing recipient number is not allowed list
can we make buttons also?
Very usefull video, thank you! i must have then open the computer in order for automation to happen if yes, how i can do then this in cloud to avoid keeping computer live 24/7 thank you!
they disabled my test number, how do i fix that?
Basically learning that this entire provided code base breaks constantly on MacOS because it has issues with homebrew installed python.
does it work for whatsapp business?
I've been trying to use this for the past couple of days. The app will randomly receive updates from Whatsapp even if I have not sent a new message. I'm glad that I was able to learn a couple of techniques but this solution seems to be pretty broken. Hoping that the next videos shows a more complete solution for creating a Whatsapp bot. Looking forward to more content :).
I am working on it! You can monitor the logs to see where they are coming from. There likely needs to be another filter for the webhooks to filter only new incoming messages.
@@SillyZillyMeThanks a lot indeed beyond words for your comment, please keep us updated to check if you manage to make it work on your side. I have a good level of Python myself and would love to use this for complex projects
already have dashboard front end?
Can we have a video on how we can connect whatsapp to one of our own custom chatbots that works on our own AI model rather than Chat-GPT
please ?
Can you make it connected to GPT-4 and other text-to-image like Fooocus?
It'd be super nice having Midjourney killer.
Did you get GPT-4 or other AI connected?
Please, zoom in , the font is very small to read and see.
We are getting the 404 found error error. No matter what we tried, it didn't work. Could it be due to a problem with our Facebook or WhatsApp line? I would be very happy if anyone got the error and explained how they solved it.
Thanks Dude. Can we add that bot in my whatsapp group and the bot able to do send messages in group
When I try to create a webhook in whatsapp configuration, it says that the ngrok URL couldn't be validated and when I try to create a webhook in webhooks it says that ngrok URL is malicious. What can I do?
same
You can use VSCode port forwarding instead of NGROK, I have gone through the same problem
@@guilhermecarlos6360 how?
@@guilhermecarlos6360 wht else u did ?
@@guilhermecarlos6360 Thanks friend, could you please explain a little further how to do that? I could not even use ngrok, meta's platform never validated my webhook url
When I try to verify my webhook, I get the following error "The callback URL or verify token couldn't be validated. Please verify the provided information or try again later." and a message on my ngrok command line interface saying GET / 502 Bad Gateway. Can anyone please suggest a way to solve it?
i have the same problem, did you fix it?
Host your application in render and use the api end point for verification
I'm in my 20s learning to be a programmer/coding, is it too late or not? I'm doubtful about my current age of 🙂
How to send video messages??
great video!! Where is the video about migrating to the real server? Many Thanks
Great video tutorial, i followed all video but i implemented server webhook using nodejs and express, everything works fine until i try to consume meta's cloud API, im getting: Recipient phone number not in allowed list: Add recipient phone number to recipient list and try again. Any thoughts?
Try not using the .env to load the enviroment variables, instead defin them in the same file as were the code is running.
Is it possible to make this bot work on a whatasapp group?
Am stuck on this error when i try to get a test message for the very first time. 400
{'error': {'message': '(#131030) Recipient phone number not in allowed list' Am certain I did everything in the documentation/video. Any solutions??
You would have to override env variable, change load_dotenv() to load_dotenv(override=True)
Did you find a way to solve this issue? i'm facing the same problem right now
@@hallohoi7741 Sorry i just figured out, in the .env file, delete the coment with the # and it works, also is witouth the +, for example if i have my spanish number should be :RECIPIENT_WAID="34xxxxxxxx", i hope it works for you now
@@hallohoi7741 did you? I'm still stuck in this part.
Found the solution in another comment by @mominali8397:
Try not using the .env to load the enviroment variables, instead defin them in the same file as were the code is running.
Is it possible to do this in a WhatsApp group?
I have a WhatsApp group with 5 people, including me.
If anybody writes a message with, for example, 'help me,' there should be an automatic reply to the group.
Is that possible? Any guide?
Please help me I am trying to the run the “call the function” paragraph to do a test text but I then end up getting errors which say no module named “requests”
It means that you don't have the "request" module installed on your local machine and it's necessary ti run the app.
In your invite, type "pip install requests" and it will install it. You're good to go then.
Thanks
Thank you! 🙏🏻
Please help me I am trying to run the "call the function" paragraph to do a test text but I get errors saying no module named "requests"?
You need to install all the dependencies
run this on your terminal - pip install requests
bro, it says forbidden when connecting webhook error 403, have you solved that problem or I am doing something wrong?
Even I am running in to same problem , Did it solve for you ?If so please share the solution
@@SairamreddyVintha-om7tg pls add the verification token u mention in the webhook setup into the .env file n check
@@ShriNanduKi Thank you it started working. This time after all the steps running into a different issue
File "C:\Program Files\Python311\Lib\ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\ssl.py", line 1075, in _create
self.do_handshake()
File "C:\Program Files\Python311\Lib\ssl.py", line 1346, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)
The above exception was the direct cause of the following exception:
Very interesting 😅
Glad you think so!
How do you fix a 500 INTERNAL SERVER ERROR?
'error': {'message': "Unsupported post request. Object with ID 'messages' does not exist, cannot be loaded due to missing permissions,? somebody ?
did you solve it?
Please make a video on how to launch functions in the assistant
That is the most important part l didnt also get .
It’s still working with ngrok? I couldn’t configure the webhook when running through this tunnel.
Same
It seems like it is not working anymore: czcams.com/video/Ltq5zByJoIQ/video.html
@@samuelpfisterer1659 it don´t work any more
try using an alternative like serveo or pinggy
For everyone running into 403, it's in the decorator. Or at least it was for me. If you comment out the security required and @security required on the views.py file you should be good to go.
Might not be the entirety of it but hopefully it sends you all in the right direction
Thank you, I had the 403 ERROR (even after copying and pasting the same TOKEN). I added a # for @signature_required in app/views.py and it worked
This unfortunately did not work for me. I've had a TON of verification issues on MacOS that have taken hours to work around. Not sure what I'm doing wrong & chatGPT can't figure it out either lol
Solved this for me: after running ngrok I had to restart the flask app. Maybe it's the order of things... Didn't need to comment out anything from the decorators
@@user-tg4vj5ou8m Yes you are right, once I followed your order of things it worked even without commenting out anything. First I ran Ngrok, then I start a fresh activation of my virtual env, started my run.py server, and finally only I went to verify and save on the Webhook configurations page. The 403 is gone then and I managed to save it. Hope this helps someone. Thank you @user-tg4vj5ou8m
@@b3armonkcan you provide more detail, do you have a web server? And do I need to add a .venv to the code
FYI my eu based ngrok domain could not be verified as a webhook callback url, it was not even called. But a non eu ngrok domain worked fine.
Hey I have the same problem here bad gateway 502 Bad Gateway how did you create a non UE ngrok domain ? should I use some VPN or sth ?
Region United States (us)
I found the solution in the ngrok.yml but still US not working
please explain how to not use ngrok domain! :)
@@3101199 - so you can create a new domain in ngrok that can be based in the eu, just not with eu in the domain name.
can this ai use in whatsapp group?