Skip to content

karamvirr/chatgpt-sms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT via SMS

A ChatGPT SMS server built using Node.js, the Twilio API, and the OpenAI API.

Usage

This project requires both a Twilio and OpenAI account.

  • Instructions for setting up a Twilio account can be found here.
  • An OpenAI developer account can be set up here.

Server setup instructions:

  • Open the terminal and change the working directory to where you want the cloned repository (ex. cd ~/Desktop).
  • Clone repository: git clone https://github.com/karamvirr/chatgpt-sms.git
  • Change the working directory to the cloned repo: cd chatgpt-sms
  • From the root, create a .env containing your OpenAI API KEY OPENAI_API_KEY and server port number PORT (port 3000 is used if not set).
  • Install dependencies: npm install
  • Run server: node server.js

We can expose this local server to the public internet using ngrok.

  • Install ngrok: brew install ngrok/ngrok/ngrok.
  • Start a tunnel: ngrok http N where 'N' is whatever value is stored in process.env.PORT (or 3000).

Screen Shot 2023-01-21 at 10 00 26 PM

Set your webhook for incoming messages in your Twilio account, as shown below. Make sure it makes an HTTP POST request on /sms. Screen Shot 2023-01-21 at 10 09 09 PM

That's it! 🥳

Now that it's configured, inbound SMS messages to your Twilio account number will trigger an HTTP POST request to the server, which will make a request to the OpenAI server and return the text from that response to the user via an outbound SMS.

Example output:

IMG_7666-2

License

This project is MIT licensed.

Releases

No releases published

Packages

No packages published