A ChatGPT SMS server built using Node.js, the Twilio API, and the OpenAI API.
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 KEYOPENAI_API_KEY
and server port numberPORT
(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 inprocess.env.PORT
(or 3000).
Set your webhook for incoming messages in your Twilio account, as shown below. Make sure it makes an HTTP POST request on /sms
.
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:
This project is MIT licensed.