Loading repository data…
Loading repository data…
chintakjoshi / repository
This is a SMS-based AI chatbot service that allows users to interact with an AI assistant by sending text messages to a designated phone number.
SMS chatbot proof-of-concept using Flask + Twilio + NVIDIA NIM (OpenAI-compatible API).
POST to this Flask app.openai Python client.app.py: thin entrypointtxtai/__init__.py: Flask app factorytxtai/config.py: env/config loading and validationtxtai/routes/sms.py: webhook + health routestxtai/services/nim.py: NVIDIA NIM integrationtxtai/services/twilio_auth.py: Twilio signature validationtxtai/utils/text_sanitizer.py: markdown and emoji cleanupDockerfile: container image for Flask appdocker-compose.yml: app + ngrok stackscripts/start-with-ngrok.ps1: start stack and print ngrok HTTPS URL.env: local secrets/config (ignored by git).env-sample: config templateCopy .env-sample to .env and fill values:
TWILIO_AUTH_TOKEN (required only when VERIFY_TWILIO_SIGNATURE=true)NVIDIA_API_KEYNVIDIA_BASE_URL (default https://integrate.api.nvidia.com/v1)NVIDIA_MODEL (pick a model available in your NVIDIA NIM account)SYSTEM_PROMPT (optional)VERIFY_TWILIO_SIGNATURE (true recommended once webhook URL is fixed)PORT (default 5000)NGROK_AUTHTOKEN (required for containerized ngrok)Twilio setup values like account SID and phone number are configured in Twilio Console for webhook routing; they are not runtime-required by this app code.
# from project root
.\venv\Scripts\Activate.ps1
python app.py
Server endpoints:
http://localhost:5000/healthhttp://localhost:5000/webhook/smsIn a second terminal:
ngrok http 5000
Copy the HTTPS forwarding URL, e.g. https://abc123.ngrok-free.app.
Assuming Docker Desktop is installed and running:
# One-shot start: builds, starts, and prints webhook URL
powershell -ExecutionPolicy Bypass -File .\scripts\start-with-ngrok.ps1
This command returns the final URL you should paste into Twilio:
https://<ngrok-domain>/webhook/sms
Manual docker commands:
docker compose up -d --build
Check ngrok API directly for tunnels:
Invoke-RestMethod http://localhost:4040/api/tunnels
Stop services:
docker compose down
https://<your-ngrok-domain>/webhook/smsHTTP POST.Now text your Twilio number and you should receive an AI reply.
VERIFY_TWILIO_SIGNATURE=true, Twilio request signatures are validated.