<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: bal simpson</title>
    <description>The latest articles on Forem by bal simpson (@balsimpson).</description>
    <link>https://forem.com/balsimpson</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F91392%2F41de6e6c-3b90-4cfa-a8e6-b1151e2feff9.jpeg</url>
      <title>Forem: bal simpson</title>
      <link>https://forem.com/balsimpson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/balsimpson"/>
    <language>en</language>
    <item>
      <title>Deploy Your Own Agentic WhatsApp Chatbot in 10 Minutes</title>
      <dc:creator>bal simpson</dc:creator>
      <pubDate>Mon, 26 Aug 2024 05:33:53 +0000</pubDate>
      <link>https://forem.com/balsimpson/deploy-your-own-agentic-whatsapp-chatbot-in-10-minutes-eh2</link>
      <guid>https://forem.com/balsimpson/deploy-your-own-agentic-whatsapp-chatbot-in-10-minutes-eh2</guid>
      <description>&lt;p&gt;Thanks to OpenAI's Assistant API, anybody can now build a WhatsApp chatbot that has capabilities like file retrieval and function calling, and can handle complex tasks seamlessly. When combined with automation tools like Make or IFTTT, the possibilities are endless — whether it’s managing your bookings, suggesting movies based on your mood, or even executing custom workflows. This tutorial will guide you through deploying your own agentic WhatsApp chatbot using Nuxt 3 and Vercel in just 10 minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;We’ll be building a movie suggestion bot that not only recommends movies based on your mood or similar to those you enjoy but also helps you keep a watchlist of movies you want to see. This bot is a simple yet powerful example of what you can achieve with the right tools and APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OpenAI API Key&lt;/strong&gt;: Sign up for an account on OpenAI and generate an API key. This will allow your bot to understand and respond intelligently to user queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TMDb API Key&lt;/strong&gt;: The Movie Database (TMDb) API is a fantastic resource for fetching movie details. Sign up on TMDb and obtain an API key to enable your bot to suggest movies based on mood or similarity.&lt;/p&gt;

&lt;p&gt;Make sure you have these keys and accounts ready before proceeding to the next steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Deploying the Template on Vercel
&lt;/h2&gt;

&lt;p&gt;I’ve created a template for the movie suggestion bot, which you can find on &lt;a href="https://github.com/balsimpson/WhatsAppAgenticBot" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. This template includes all the necessary files and configurations, so you can deploy the bot to Vercel with just a click.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fbalsimpson%2FWhatsAppAgenticBot&amp;amp;env=WHATSAPP_ACCESS_TOKEN,OPENAI_KEY" rel="noopener noreferrer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9pM3HM9F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://vercel.com/button" alt="Deploy with Vercel" width="92" height="32"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create a KV Store on Vercel
&lt;/h2&gt;

&lt;p&gt;We will use the Vercel provided KV Store to simplify keeping track of message threads and watchlist. This is not a very scalable option, but it is arguably the simplest.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Go to your Vercel dashboard and choose &lt;code&gt;Storage&lt;/code&gt;. &lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprioozwaufekmgwau922.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprioozwaufekmgwau922.png" alt="Image description" width="800" height="290"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Click on &lt;code&gt;Create database&lt;/code&gt; and choose KV&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqncqmsmw4lt7ok11jrv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqncqmsmw4lt7ok11jrv.png" alt="Image description" width="800" height="778"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Choose Continue and Vercel will create a persistent Storage for you that you can access from anywhere in your app. It will also automatically add environment variables for the KV Store including &lt;code&gt;KV_REST_API_URL&lt;/code&gt; and &lt;code&gt;KV_REST_API_TOKEN&lt;/code&gt;. Check the project environment variables to make sure these have been det, redploy to make sure. &lt;/p&gt;

&lt;p&gt;Go to &lt;code&gt;https://your-bot-name.vercel.app&lt;/code&gt; and the frontend should show interactions you have with your bot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Connect Your Meta WhatsApp Account to Vercel
&lt;/h2&gt;

&lt;p&gt;Now that your bot is deployed on Vercel, the next step is to connect it to your Meta WhatsApp account by configuring a webhook. This will allow WhatsApp messages to be sent to your bot and responses to be returned.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WhatsApp Test Number on Meta&lt;/strong&gt;: To interact with users on WhatsApp, you’ll need a test number. Set up a WhatsApp Business Account via Meta and configure a test number through the WhatsApp Business API.&lt;a href="https://developers.facebook.com/apps/" rel="noopener noreferrer"&gt;Click here to get started&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/balsimpson/create-a-chatgpt-whatsapp-bot-on-cyclic-in-just-5-minutes-l4a"&gt;Refer to this link to setup.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Set Up a Webhook URL:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In your Vercel dashboard, locate the deployed project.
Find the URL for your deployment (e.g., &lt;a href="https://your-bot-name.vercel.app" rel="noopener noreferrer"&gt;https://your-bot-name.vercel.app&lt;/a&gt;).
Note this URL, as it will be needed for the webhook configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Configure the Webhook in Meta for Developers:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to the Meta for Developers portal and select your WhatsApp app.&lt;/li&gt;
&lt;li&gt;Navigate to the "Webhook" section under "WhatsApp."&lt;/li&gt;
&lt;li&gt;Click "Add Webhook" and paste your Vercel deployment URL, appending /api/webhook to it (e.g., &lt;a href="https://your-bot-name.vercel.app/api/webhook" rel="noopener noreferrer"&gt;https://your-bot-name.vercel.app/api/webhook&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Select the specific events you want to subscribe to (choose messages).
Save your changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Verify the Webhook:
&lt;/h3&gt;

&lt;p&gt;Choose anything as your verification code and click "Verify webhook". Meta will send a verification request to your webhook URL and it should get verified.&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing:
&lt;/h3&gt;

&lt;p&gt;Send a test message to your WhatsApp Test Number to ensure everything is working correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Setting Up the OpenAI Assistant in Playground
&lt;/h2&gt;

&lt;p&gt;The next step is to setup the assistant. We'll use OpenAI's Playground to set it up and configure the bot to suggest movies, and optionally, return a list of movies with IMDb ratings and synopses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Access the OpenAI Playground:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to the OpenAI Playground.&lt;/li&gt;
&lt;li&gt;Log in with your OpenAI account.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Set Up the Assistant:
&lt;/h3&gt;

&lt;p&gt;Click on Create to create a new assistant.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ef1hisahs25cek55jy1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ef1hisahs25cek55jy1.png" alt="Image description" width="800" height="711"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Give your assistant a name. I named mine Ebert.&lt;/li&gt;
&lt;li&gt;Add instructions. It can be as simple as:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;You are a helpful assistant that suggests movies based on the user's mood or preferences. When asked, you also provide a list of movies with IMDb ratings and a brief synopsis. For example, if the user says they are in the mood for a thriller, suggest a few options along with their IMDb ratings and a short description.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Set the model
&lt;/h3&gt;

&lt;p&gt;Choose the model that will be used by the Assistant. &lt;code&gt;gpt-4o-mini&lt;/code&gt; is the cheapest and works for most tasks. &lt;/p&gt;
&lt;h3&gt;
  
  
  Create Vector Store and Add Files
&lt;/h3&gt;

&lt;p&gt;The vector store is an awesome addition to the new Assistants API that required multiple steps and third-party tools to achieve what you can do now with minimal friction.&lt;/p&gt;

&lt;p&gt;Got to &lt;a href="https://platform.openai.com/storage/vector_stores" rel="noopener noreferrer"&gt;Vector store&lt;/a&gt; to add the files the Assistant can reference, if need be. The free tier is quite generous and you can add up to 1GB of documents without being charged. All documents will be vectorised and be available to the assistant.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb023gt5tket28zl543y1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb023gt5tket28zl543y1.png" alt="Image description" width="800" height="284"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Add Functions
&lt;/h3&gt;

&lt;p&gt;Functions is what makes Assistants so powerful. They enable you to do tasks like fetching information from an external API, or add a new row to Google Sheets using Make.com.&lt;/p&gt;

&lt;p&gt;You can specify the properties that are required for the function to be triggered and the chatbot will ask questions till those slots are filled. before trying to execute the function.&lt;/p&gt;

&lt;p&gt;For our chatbot we will add two functions:&lt;br&gt;
&lt;code&gt;add_to_watchlist&lt;/code&gt; - This function will get triggered when the user says something like "Save The Raid to my watchlist".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "add_to_watchlist",
  "description": "Adds a movie or TV show to the user's watchlist when they express interest in watching it later.",
  "strict": true,
  "parameters": {
    "type": "object",
    "properties": {
      "name": {
        "type": "string",
        "description": "The name of the movie or tv show that needs to be added to the watchlist"
      }
    },
    "required": [
      "name"
    ],
    "additionalProperties": false
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;get_movie_tvshow_details&lt;/code&gt; - Function to fetch movies/ tv show details from TMDb when user says something like "Tell me more about Memento".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "get_movie_tvshow_details",
  "description": "Get more info about the movie or tv show the user asked for from TMDb",
  "strict": true,
  "parameters": {
    "type": "object",
    "properties": {
      "title": {
        "type": "string",
        "description": "The title of the movie or tv show"
      },
      "type": {
        "type": "string",
        "description": "The type of media - movie or tv. Guess if not provided"
      }
    },
    "required": [
      "title",
      "type"
    ],
    "additionalProperties": false
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all you need to do to be up and running. Note the Assistant ID.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgua5i8eemiz8bo27u813.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgua5i8eemiz8bo27u813.png" alt="Image description" width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Update your code with the assistant id
&lt;/h2&gt;

&lt;p&gt;Add the Assistant Id to &lt;code&gt;/server/utils/assistantConfig.ts&lt;/code&gt;. You can even serve up different assistants depending on user name if you want to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Verify chatbot
&lt;/h2&gt;

&lt;p&gt;Go to Vercel dashboard and to your project deployment to monitor incoming requests from WhatsApp. Send a message to your chatbot and you should get a reply. &lt;/p&gt;

&lt;p&gt;Currently the chatbot will keep a thread for 15 minutes, but you can change that in &lt;code&gt;/server/utils/assistantHelpers.ts&lt;/code&gt; by changing the value of &lt;code&gt;THREAD_MAX_TIME&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Use cases
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Capture structured info
&lt;/h3&gt;

&lt;p&gt;You can capture structured responses through natural dialogue, be it for a YouTube idea to be added to Notion or adding a row to Google Sheets for your AirBnB booking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Output structured info
&lt;/h2&gt;

</description>
      <category>openai</category>
      <category>vercel</category>
      <category>nuxt</category>
    </item>
    <item>
      <title>Create a ChatGPT WhatsApp Bot on Cyclic in Just 5 minutes</title>
      <dc:creator>bal simpson</dc:creator>
      <pubDate>Tue, 10 Jan 2023 16:36:09 +0000</pubDate>
      <link>https://forem.com/balsimpson/create-a-chatgpt-whatsapp-bot-on-cyclic-in-just-5-minutes-l4a</link>
      <guid>https://forem.com/balsimpson/create-a-chatgpt-whatsapp-bot-on-cyclic-in-just-5-minutes-l4a</guid>
      <description>&lt;p&gt;ChatGPT is the current rage and I thought it would be fun to make a WhatsApp bot that I can interact with instead of going to the website. It uses the &lt;strong&gt;OpenAI API&lt;/strong&gt; and can be modified to create Dall.E 2 images too. So let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 - Setup WhatsApp Test Number
&lt;/h2&gt;

&lt;p&gt;Go to &lt;strong&gt;&lt;a href="https://developers.facebook.com/apps/" rel="noopener noreferrer"&gt;Facebook Developer Page&lt;/a&gt;&lt;/strong&gt; to create an app.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbu2au4t0l3zvanuh85sz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbu2au4t0l3zvanuh85sz.png" alt="Create a Facebook App" width="800" height="63"&gt;&lt;/a&gt;&lt;br&gt;
Choose &lt;strong&gt;Business&lt;/strong&gt; as your app type and click next.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ljcq639mto49pkduvas.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ljcq639mto49pkduvas.png" alt="Choose Business as your App Type" width="800" height="248"&gt;&lt;/a&gt;&lt;br&gt;
Give your app a &lt;strong&gt;name&lt;/strong&gt; and create the app.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe11wjqf1cn5f5yl6k1d2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe11wjqf1cn5f5yl6k1d2.png" alt="Create a Facebook App" width="800" height="359"&gt;&lt;/a&gt;&lt;br&gt;
On the app page you just created, you will see options for products to add. Click on &lt;strong&gt;WhatsApp&lt;/strong&gt; to set it up. &lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe3fga1g3d35tp63e6k3m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe3fga1g3d35tp63e6k3m.png" alt="Setup WhatsApp" width="800" height="522"&gt;&lt;/a&gt;&lt;br&gt;
This will take you to the &lt;strong&gt;Getting Started&lt;/strong&gt; page. Facebook assigns a test number to you, but you need to get permission from every phone number (upto 5) that will interact with the bot.&lt;/p&gt;

&lt;p&gt;Click on &lt;code&gt;Manage phone number list&lt;/code&gt; to add your number.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxua5zccgu61kryppbmj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxua5zccgu61kryppbmj.png" alt="Add a phone number" width="800" height="522"&gt;&lt;/a&gt;&lt;br&gt;
As soon as you add the number an OTP will be sent to that number. Enter it to complete the process.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxl6eyykpn4gyrbitg7cy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxl6eyykpn4gyrbitg7cy.png" alt="Enter your OTP" width="683" height="368"&gt;&lt;/a&gt;&lt;br&gt;
Now choose the number you added from the dropdown list and &lt;strong&gt;send a test message&lt;/strong&gt;. You should get a Welcome message from your bot.&lt;/p&gt;

&lt;p&gt;Copy the temporary &lt;strong&gt;Access Token&lt;/strong&gt; and note it down somewhere as we will need it when we deploy our bot to &lt;a href="https://www.cyclic.sh/" rel="noopener noreferrer"&gt;Cyclic&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You might need to create a permanent token for continued usage.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Step 2 - Signup for OpenAI
&lt;/h2&gt;

&lt;p&gt;Go to &lt;a href="https://openai.com/api/" rel="noopener noreferrer"&gt;OpenAI&lt;/a&gt; to get an API key. Once you are signed up, click on your profile image and go to &lt;strong&gt;View API keys&lt;/strong&gt; to get your key.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmushs8ftk0n0fcbi6qyv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmushs8ftk0n0fcbi6qyv.png" alt="Get your OpenAI key" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3 - Deploy bot on cyclic.app
&lt;/h2&gt;

&lt;p&gt;Go to &lt;a href="https://www.cyclic.sh/" rel="noopener noreferrer"&gt;Cyclic&lt;/a&gt; and sign in with your Github account.&lt;/p&gt;

&lt;p&gt;Or you can just click the button below to automatically pull the right repository and install the app.&lt;br&gt;
&lt;a href="https://deploy.cyclic.app/balsimpson/whatsapp-chatgpt" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdeploy.cyclic.app%2Fbutton.svg" alt="Deploy to Cyclic" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This did not work for me for some reason. If it doesn't work for you, create a starter app on cyclic and then copy the code from this &lt;a href="https://github.com/balsimpson/whatsapp-chatgpt" rel="noopener noreferrer"&gt;repository&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you have created the app, go to the &lt;code&gt;Variables&lt;/code&gt; tab to add the &lt;code&gt;WHATSAPP_ACCESS_TOKEN&lt;/code&gt; and the &lt;code&gt;OPENAI_KEY&lt;/code&gt;. You need to spell it exactly that.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ide93zpzhal7vr7dx8d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ide93zpzhal7vr7dx8d.png" alt="Add your environment variables" width="800" height="547"&gt;&lt;/a&gt;&lt;br&gt;
Note the &lt;code&gt;CYCLIC_URL&lt;/code&gt; down which we'll use in the next step to complete the connection with Facebook.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can go to the &lt;code&gt;Environments&lt;/code&gt; tab to give your URL a personal touch.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Step 4 - Connect to Facebook
&lt;/h2&gt;

&lt;p&gt;Now go back to your app on Facebook and choose &lt;code&gt;Configuration&lt;/code&gt; to &lt;strong&gt;configure the webhook&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqdp8b5z15m09kzon4a8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqdp8b5z15m09kzon4a8c.png" alt="Configuration screen" width="800" height="262"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter &lt;strong&gt;&lt;code&gt;CYCLIC_URL&lt;/code&gt;/webhook&lt;/strong&gt; as the callback URL and any random text as token and click on &lt;code&gt;Verify and save&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprawz0i2txs2fa59n7wz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprawz0i2txs2fa59n7wz.png" alt="Configure your webhook URL" width="700" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The last step is to subscribe to messages. Just under the callback URL you just added, you'll see &lt;strong&gt;webhook fields&lt;/strong&gt;. Click on &lt;code&gt;Manage&lt;/code&gt; and then subscribe to &lt;code&gt;Messages&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgza7h3b7kzio7ytko2ux.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgza7h3b7kzio7ytko2ux.png" alt="Subscribe to messages" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it! Now on WhatsApp, send your bot (the one you received the test message from) a message like &lt;code&gt;Deploy a ChatGPT WhatsApp Bot on Cyclic in just 5 minutes - give me some options for this headline&lt;/code&gt; and it should respond in about 5-6 seconds. Have fun!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can go to the &lt;code&gt;Logs&lt;/code&gt; tab on cyclic to see a realtime log of your communication with WhatsApp. The &lt;code&gt;Transactions&lt;/code&gt; tab also shows the whole &lt;code&gt;request&lt;/code&gt; and &lt;code&gt;response&lt;/code&gt; for every single message.&lt;/p&gt;

&lt;p&gt;You can easily change from &lt;code&gt;TextCompletion&lt;/code&gt; to &lt;code&gt;ImageGeneration&lt;/code&gt; by calling the &lt;code&gt;createImage&lt;/code&gt; method on &lt;code&gt;openai&lt;/code&gt; instead of the &lt;code&gt;createCompletion&lt;/code&gt; method. You'll need to modify the &lt;code&gt;sendMessage&lt;/code&gt; function according to the documentation to send an image instead of text.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body: JSON.stringify({
    messaging_product: "whatsapp",
    to: from,
    type: "image",
    "image": {
      "link": generatedImg,
    }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the code is available at this Github &lt;a href="https://github.com/balsimpson/whatsapp-chatgpt" rel="noopener noreferrer"&gt;repository&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>help</category>
      <category>learning</category>
      <category>networking</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
