How To Connect OpenAI To WhatsApp (Twilio & Python Tutorial)

1.73k views2120 WordsCopy TextShare
Lena Shakurova | AI, chatbots and voice agents
šŸ”” Follow me on LinkedIn for more tips on GenAI & Conversational AI: https://www.linkedin.com/in/len...
Video Transcript:
hi everyone welcome back to this channnel in today's video I'm going to show you how to connect your business WhatsApp phone number with open AI there are actually different ways how to connect an AI system to Whatsapp many of those are no code but sometimes we developers don't want to depend on third party provider and we want to set up our own WhatsApp connections we can actually do that using python and a tool called twio however it's not that simple video to Whatsapp connection is not super trivial and I couldn't find a nice video online explaining the setup process step by step so I thought I'll create my own one so if you want to build an openi system connected to Whatsapp using python then this video will be super helpful for you I prepared a GitHub repository written fully in Python that we will use to make this process super simple and fast I'll show you how to properly set up tum how to get your open AI IP key and how to spin up this GitHub repository so that your WhatsApp AI assistant is up and running all right let's get started shall we first you'll have to open the GitHub repository that will share with you in the comments below this REO has all the python code that you would need and it's built using the following text tag we'll use Docker fast IP toio to connect WhatsApp open AI for using the llm model and radi to store conversations in the memory what you need to do is you need to clone the repository using this link which I already did and once you do that you will have the following setup let's have a look at the folder structure we have a Docker file here Docker compose also in the main folder and the requirements file then we have the app folder that has a main. py file which is the main file that connects everything together and it calls other modules like cookies utils that talks to radius and stores the cookies gets the cookies and clears the cookies then we have logger U just for the logs we have open AI utils that has the code to run open AI models as you will notice you can also connect it to other models that you like we are using a library called light llm that is model agnostic which is very convenient you just need to provide your respective API keys and the model name and then you can use it open a utils file also has a function called summarized conversation which is going to take the last 70 turns of the conversation and write a short summary using one of the cheapest and fastest open a models and then we'll pass this to our prompt for some context so that our chatbot is better aware of what is happening without having too long of a conversation history which impacts the speed another file we have here is prompts dopy this one has summary prompt which will summarize the conversation and the system prompt which is the main prompt in this tutorial we are going to be creating a brainstorming assistant that's going to act as a brainstorming body you can ask it any kind of question and it will ask you followup questions and offer you some suggestions we are not going to focus on the system prompt here in this video because the goal is to learn how to connect to Whatsapp using 3o all right and the last file is a radius file which opens up the radius connection now that we know the folder structure let's set everything up the first thing you'll need to do is to make make sure that you already have Docker and radi installed on your machine I already have that so I will skip that step the next thing you need to do is to copy n. example file and paste all your credentials here we will need twer credentials open AI credentials and R credentials let's start with open AI to get your openi key you need to go to platform.
open. com do settings. organization and I keys I already have some keys but if you don't have any Keys then you'll probably have to connect your bank account to open a playround and then click create new key add a name let's call it videoo test key select the project I'll select default project and click create secret key afterwards you have to copy this key immediately you will not be shown it afterwards so you need to save it uh in a good place and you go to yourn file uh which will look like this and you paste your open a key like this without any quot then we'll need to set up our twio account we will start with using twio sandbox first first we need to copy our account seat and paste it to our environment file then we need to copy our token and paste it here and then we need to get really WhatsApp number which is what we will need sandbox for to set up sandbox you'll need to go to messaging and click try it out send a WhatsApp message T sandbox setup is rather simple you need to go to your WhatsApp click on scan QR code and scan the QR code code then the too chat will open automatically and you will be asked to paste a code I send a code and twio sandbox says you are all set that's perfect now we have a phone number from twio which looks like this and we will need to paste it here just like this that's it for the T sendbox setup now you only need to paste information about your radi host port and password and I'm not going to spend too much time on this you can find documentation online on how to do that it is rather straightforward now now let's quickly test that the send boox Works let's click Send template message and you can see on your WhatsApp phone number that the message was received so the send box is working that's perfect all right now let's try to spin up this repository what we would need to do is copy this command Docker compose up and paste it here and wait until it's up and running okay it seems that it's working now let's verify it using Postman here I have the URL which you can find in your app.
Related Videos
From Zero to Your First AI Agent in 25 Minutes (No Coding)
25:58
From Zero to Your First AI Agent in 25 Min...
Futurepedia
128,092 views
Getting Started with CrewAI Open Source
14:21
Getting Started with CrewAI Open Source
CrewAI
10,340 views
Starmer reverses BREXIT before his EXIT
17:06
Starmer reverses BREXIT before his EXIT
The Duran
54,013 views
OpenAI Agents SDK Tutorial (FULL SERIES)
2:30:55
OpenAI Agents SDK Tutorial (FULL SERIES)
Kody Simpson
5,556 views
How To Connect OpenAI To WhatsApp (Python Tutorial)
30:31
How To Connect OpenAI To WhatsApp (Python ...
Dave Ebbelaar
213,393 views
Building a Fully Automated WhatsApp AI Chatbot
17:58
Building a Fully Automated WhatsApp AI Cha...
Eduardo Vasquez
863 views
Master Voiceflow in 2 Hours: Complete Beginner's Guide for 2025
1:52:13
Master Voiceflow in 2 Hours: Complete Begi...
Eddie The Chenster | AI Automation
2,981 views
How to make your AI voice agent sound (more) human
12:02
How to make your AI voice agent sound (mor...
Lena Shakurova | AI, chatbots and voice agents
690 views
Why Mark Zuckerberg’s Rebrand Is So Suspicious
13:32
Why Mark Zuckerberg’s Rebrand Is So Suspic...
More Perfect Union
468,038 views
Python Twilio - Python Send Whatsapp Message - Twilio Whatsapp API - Python Twilio for Beginners
17:27
Python Twilio - Python Send Whatsapp Messa...
Code Jana
55,658 views
How to Build & Sell AI Agents: Ultimate Beginner’s Guide
3:50:40
How to Build & Sell AI Agents: Ultimate Be...
Liam Ottley
763,784 views
Why CIA says China is Prepping Massive Invasion
26:18
Why CIA says China is Prepping Massive Inv...
Cappy Army
454,225 views
Sell AI Systems, Not AI Agents (how I made $5,407,902 last year)
26:46
Sell AI Systems, Not AI Agents (how I made...
JP Middleton
98,963 views
How To Integrate Twilio WhatsApp Chatbot To Your Business
19:15
How To Integrate Twilio WhatsApp Chatbot T...
Adeshola Olaitan
173 views
How to Build Your First AI Agent in MINUTES
11:31
How to Build Your First AI Agent in MINUTES
MindStudio
10,785 views
MCP vs API: Simplifying AI Agent Integration with External Data
13:11
MCP vs API: Simplifying AI Agent Integrati...
IBM Technology
247,262 views
AI Agents Fundamentals In 21 Minutes
21:27
AI Agents Fundamentals In 21 Minutes
Tina Huang
1,028,119 views
Tutorial: WhatsApp AI Support Agent with RAG & Memory (PydanticAI, LangGraph, Supabase, FastAPI)
34:43
Tutorial: WhatsApp AI Support Agent with R...
Dani FuyĆ 
1,156 views
Can you really create AI voice agents just by talking? (Lovable tutorial)
17:04
Can you really create AI voice agents just...
Lena Shakurova | AI, chatbots and voice agents
1,756 views
ChatGPT Tutorial 2025 - [Become An AI Power User in 30 Minutes]
21:58
ChatGPT Tutorial 2025 - [Become An AI Powe...
Santrel Media
26,793 views
Copyright Ā© 2025. Made with ♄ in London by YTScribe.com