Create Your Own WhatsApp ChatGPT Chatbot Using Termux

  Developing a chatbot can be an enjoyable endeavor with the added benefit of streamlining your business or personal interactions.



This guide will walk you through the steps of creating a WhatsApp chatbot using ChatGPT, OpenAI's powerful language model. Our aim is to build a bot that can intelligently reply to WhatsApp messages using natural language processing.


Here is the code to create a WhatsApp bot using OpenAI bot and NodeJS. The bot is capable of understanding natural language and offering responses on various topics. It can answer queries, offer recommendations, and engage in conversations with users. By following these instructions, you can develop a powerful bot that serves a multitude of functions.


What is WhatsApp ChatBot?


1. OpenAI was founded in 2015 in San Francisco by Elon Musk, Sam Altman, Greg Brockman, Wojciech Zaremba, Ilya Sutskever, and John Schulman. Their mission was clear yet ambitious: to develop safe and accessible AI tools that enhance human capabilities instead of replacing them.


What Is ChatGPT?


ChatGPT, developed by OpenAI, is a cutting-edge AI bot crafted by Alta Blum, Musk, and other prominent Silicon Valley backers. This nonprofit entity, dedicated to AI exploration, was unveiled on November 30, 2022. Serving as a Pre-Trained Transformer for Chat, ChatGPT stands out as the ultimate machine for understanding human language, effortlessly generating intricate texts that resonate with humans. Its interactive question-and-answer technique adds an engaging touch to its functionality.


Requirements for the Trick

  1. Termux Apk (Latest Version)
  2. Phone Storage (Minimum 300Mbs)
  3. Network
  4. Node JS (npm)
  5. Video guide coming soon

STEP 1: Download the Termux apk

  1. Remove the outdated Termux version and install the most recent update of Termux.
  2. Begin by opening the F-Droid.org website or app on your Android device.
  3. Look for the Termux application.
  4. Tap on the Download button to install it on your Android phone.
  5. The app will be downloaded to your device.


Install App Tools In Termux

STEP 1:  Prior to installing any tool, it is essential to update all pre-installed packages to avoid encountering issues when using Apk-Tool in Termux. Execute the following command to upgrade packages in Termux. This will ensure a smooth installation process for WhatsApp Chatbot.


apt update -y && apt upgrade -y

 

STEP 2: ChatGPT project is available on GitHub, Git needs to be installed in Termux to download the project from the GitHub repository. Just enter the command provided below and the Git package will be installed immediately.

apt install git -y

STEP 3: 1. Please input the necessary dependencies for this tool. This will enable the inclusion of curl, wget, ruby, and git in Termux and Linux for future use. After completing this step, you can omit the name from the command when executing the package installer.

apt install nodejs -y

apt install nodejs-lts -y

apt install nano -y

 

STEP 4: 1.All dependencies have been successfully installed in your Termux. Now, you can proceed with the installation of the ChatGPT WhatsApp Bot by executing the command provided below. To check the file size of this tool, simply copy and paste the command below. Within approximately 20 seconds, the tool will be fully loaded and ready to use.


 git clone https://github.com/OnlineHacKing/Whatsapp-ChatGPT


STEP 5: To switch to the WhatsApp-ChatGPT directory, simply use the "cd" command. If you're unfamiliar with this command, it's essential to learn it. Execute the following command in the Termux Terminal and hit Enter.


cd Whatsapp-ChatGPT


STEP 6: By scanning npm install commands, certain required packages for node.js will be fetched and the bot will start running. 


Utilize the Node.js client library to connect with the WhatsApp web browser application. The OpenAI Node.js library simplifies access to OpenAI APIs in Node.js applications. Our chatbot application will be developed using this library in the upcoming stages.


npm install


Access the nano api.json file using a text editor and input the environmental variable containing your OpenAI account API key:


Update the API's in the api.json file by inserting the OpenAl API Key, then remember to save the changes. Also, don't forget to configure CURLOPT_HTTPAUTH and CURLAUTH_..


To obtain an API key for the OpenAI API, you must first create a complimentary OpenAI account on the OpenAI website (https://openai.com).


How to get an OpenAI API

To create an account, simply click on the "Sign Up" button located at the top right corner of the homepage. Follow the provided instructions to successfully set up your new account. Once your account is created, you can find your API key in the "API" section of your account settings.


Within the "API" section, locate the "Generate API Key" button. By clicking on this button, you can generate a fresh API key specifically for your Node.js application to access the OpenAI API. It is crucial to exercise caution and never share your API key with any third party under any circumstances.


Please update your API key by replacing the text "INSERT YOUR OPENAI API KEY" in the desktop/desktop.py/api.json file with your actual API key.


To add the OpenAl API Key to the api.json file, open the file and save it. Then, use CURL +X and press Y followed by Enter.


STEP 8: To initiate this OpenAI ChatGPT bot, simply input the command in the command line.


node index.js


The QR code should be displayed correctly on the command line output, showcasing the lamb's behavior as an example of anticlimax that led Aristotle to reject it as a scene of reversal.


After scanning the QR code using the WhatsApp mobile application, you will be able to validate it and view the following message:


How to scan QR Code in Whatsapp App



  • Open WhatsApp App
  • Click to the three dots at the top right corner
  • Click the Link Devices Button and then click the link a device Button.
  •  Scan the QR code

The Chatbot is now running, showing a list of messages. Put the # character and make your questions like a WhatsApp post. The response is then generated by OpenAI and automatically accepted as a reply to the original message: If the companies in 

The integration between OpenAI and WhatsApp is complete! The WhatsApp chatbot is already working tirelessly and providing responses via WhatsApp.


NOTE: 1. If the bot fails to respond, try restarting Termux and then restart the bot to ensure a response.


 Extra details (Optional) 

To ensure continuous operation of this WhatsApp Bot around the clock, you can utilize replit for free.


STEP 1:  Afterwards, proceed to the replit.com webpage and establish a fresh account (in case you do not possess an existing one), or simply sign in to your previous account.


Deploying WhatsApp bot to Replit

STEP 2: Clicking on the Made with Replit button will open a new page, which is the Replit website. To start creating a Replit, simply click on the Create Replit Button, choose Node.js as the language, and enter a name.


Run on Repl.it

STEP 3: 1. Access the bot file on GitHub and proceed to download it. Remember to unzip the file before continuing. Mobile users can either tap the Play button or the three dots at the top. Make sure to upload all bot files once downloaded.


STEP 4: When the Start button is clicked, a Popup Message will be displayed. Open the api.json file and replace the text INSERT YOUR OPENAI API KEY with your own API key.

STEP 5: Once you have successfully entered a valid API key, a 'start' button will become visible. Simply press the space bar and, if it is already enabled, click on both the 'stop' and 'start' buttons. Afterward, open the terminal window and scan the QR code in WhatsApp.


DISCLAIMER

The information provided in the article is solely for educational purposes and does not constitute investment advice. It is important for both investors and professionals to seek their own independent financial advice. Conduct thorough research and consult with financial experts before making any investment decisions. Please note that Analytics Insight and its team are not responsible for any investment opinions expressed in this article.



0 Comments