The goal of this project is to reduce constant staff interruptions by replacing direct texts with a virtual assistant. This AI-powered SMS assistant answers common questions and escalates anything it can’t handle to a manager, learning from their response.
- User texts the business number (we use Twilio).
- Assistant checks:
- Hardcoded
qa.jsonprompt (QA_TEXT) - Previously learned answers from Supabase
qa_pairstable
- Hardcoded
- If a match is found:
- Assistant replies with the appropriate answer
- If no match:
- Assistant responds:
"Let me forward this to a manager." - Manager is alerted via SMS
- Assistant responds:
- When the manager replies:
- Their response is forwarded to the original user
- The Q&A pair is saved for future use
The assistant is instructed to only answer using approved information:
"You must answer employee questions ONLY using the exact information provided... If you cannot find the answer in the information below, respond with exactly:
Let me forward this to a manager."
- OpenAI GPT-3.5 Turbo –> Language model for generating responses
- Twilio –> Handles SMS send/receive
- Supabase –> Stores Q&A pairs and escalation logs
- AWS SAM –> For packaging and deploying serverless functions
- Node.js –> Backend logic
- Modularize all the core logic into helper files like (db.js, ai.js, sms.js, utils.js)
- Clean up the redundant code in index.mjs and centralize the Twilio/Supabase client setup
- Handle concurrent incoming messages (race conditions)
- Create a dashboard for the manager to review/edit answers