First of all, being the owner of a WhatsApp Business Account, you have to meet customers’ inquiries and demands. All that consumes a significant portion of your daytime, and you begin to search for a solution – a chatbot.
In particular, the one that utilizes ChatGPT to answer your clients’ questions reasonably and reasonably. If you want to learn how to link WhatsApp to ChatGPT and create that chatbot…well, keep reading.
This is what you need to know on how to integrate ChatGPT into WhatsApp
You will need the following to finish the integration:
This paper presents an Application Programming Interface (API) for a ChatGPT.
A WhatsApp Business Account
Pipenv
Python 3.7 or above
Go
How to Access the ChatGPT API
To activate ChatGPT API, nonetheless, you don’t need to worry because all you require is an OpenAI account to get started. Follow these steps:
Step 1: Visit the OpenAI Platform and either enter your credentials and proceed to the platform or if a new user, click on the ‘Sign Up’ button. It is also possible to sign up with the Google, Apple or Microsoft account using the relevant buttons.
Step 2: When one is creating a new account, they have to fill in their name, company name; which is not mandatory and birthday then click an “Agree” button.
Step 3: On the next screen, select “API”.
Step 4: Click on ‘Dashboard’ from the list of options along the top and go to ‘API Keys’ on the left-hand side.
Step 5: In the top-right corner you can click on the button “Start Verification” and in the window that will appear you enter your telephone number. Click on “Send Code” to have OpenAI text you the verification code to your Smartphone.
Step 6: You will then be prompted to input the six-digit code you have received after which you detail your usage case to OpenAI then click the submit button.
Step 7: From the option at the top right of the page or the button in the middle of the page, choose “Create new secret key”.
Step 8: Choose Key and click on Generate secret keys.
Step 9: Paste it to another document you can access and then press the “Done” button to save your secret key. You can not access it again because it disappears therefore, it is wise you copy it so that you can use it sometime later.
Integrate ChatGPT with WhatsApp Using the API
However, in terms of regularly used standard accounts, it is currently impossible to integrate ChatGPT with WhatsApp. You have to be a WhatsApp Business user because only this service offers the necessary WhatsApp API for connecting ChatGPT to WhatsApp.
The WhatsApp Business app can be downloaded from the Google Play Store or App Store for Android and iPhone, respectively, and installation is as normal as installation of any other app in the respective store
Dispersing pre-configured ChatGPT prompts to users for immediate application into WA 15
Once you’ve installed WhatsApp Business, you need to create a Pipenv Python Script to enable the interoperation of WhatsApp with ChatGPT.
Step 1: Download Pipenv. While using this venv, it is encouraged that you practice running Python 3.7 or above on your device.
Step 2: This is where Denis Kuria of Makes Use Of gets the code from. The OpenAI, Django, and Djangorestframework packages can be installed by entering them into Pipenv.
pipenv install django djangorestframework openai
Step 3: To create a new Django project, you should use the code from the current tutorial: Start by opening the terminal and then Typing django-admin startproject WhatsApp
Step 4: In the new directory of WhatsApp that you have just created, create a new Django app and call this new app “gpt” using the following command.
py manage.py startapp gpt
Step 5: Go to the “whatsapp/settings.py” and in the “INSTALLED APPS” add “gpt”. The last part of typing should look like this at the bottom of the list above “].” Type ‘gpt’.
Step 6: Navigate to “whatsapp/urls.py” and add the “gpt” app URL using the following code as below:
import admin from django.contrib
import django.URLs/
It is much easier now to simply write import django. URLs and then write all URL paths to extend from this.
urlpatterns = [
…
path(‘api/’, include(‘gpt.urls’)), # gpt app URL
]
Step 7: The following code snippet should be used to generate a view for your ChatGPT API, visit the “gpt/views.py” file. Do not miss the “openai.api_key” variable of the following code. The following is the portion enclosed in quote marks where you will insert the secret key that you created with OpenAI:
from rest_framework.response import Response
import openai
imported rest_framework.views as APIView
class OpenAIGPTView(APIView):
def get(self, request):
input = request.GET.get(‘q’)
openai.api_key = “insert the openai API key here ”
completion = openai.ChatCompletion.create
model=”gpt-3.5-turbo”,
messages=[{“role”: “user”, “content”: input}]
)
answer = completion message containing the choice with content
return Response(answer)
How to Register Your New API
You now have an API endpoint which would make a GET request with your customer input to ChatGPT and Open AI’s generative response model. You have to register this endpoint and then bring it into the WhatsApp.
Step 1: Make a file with a name “urls.py” and write the code below in order to register your API:
from django.urls import path
from .views import *
urlpatterns = [
path(‘chat’, OpenAIGPTView.as_view()),
]
Step 2: Write the following commands to start your API endpoint both the “runserver” and “migrate” commands.
python manage.py migrate
python manage.py runserver
Step 3: If you haven’t already, I encourage you to download and install the latest version of Go on your device. This will make you a client of Whatsmeow.
Here we shared with you How to Integrate ChatGPT into WhatsApp, which will help you to use it efficiently and effectively in your business organization.
Step 4: Copy the “Whatsmeow” client from the given Json file into Pipenv using the following command line:
git clone https:>< SpeakingOf WhatsApp > //github.com/Huskynarr/whatsapp-gpt.git
Step 5: Navigate to this link and look for the file called main.go in the whatsapp-gpt repository. You should find the following line of code:
url :”> http://localhost:5001/chat?q= + urlEncoded
Replace the line with:
url :=”http://127.0.0.1:8000/api/chat?q=” + urlencode
Step 6: Make your changes then build the file you have created by entering Pipenv go run main.go. You will be taken to a screen containing a QR code.
Step 7: Scan can be done through opening the WhatsApp business app, go to Settings, then to QR Code and Scan Code. If you have received a WhatsApp business number message, you just need to scan the QR code and you are in, the moment you are logged in you have been able to connect WhatsApp to ChatGPT.