# SMS Debugging Guide

## Quick Check

1. **Check if token is set:**
   ```bash
   # In backend directory
   node -e "require('dotenv').config(); console.log('Token:', process.env.TEXT_LK_API_TOKEN ? 'SET' : 'NOT SET');"
   ```

2. **Check backend console when submitting inquiry:**
   - Look for messages starting with 📤, 🔑, 📞, 🌐, etc.
   - Check for error messages with ❌
   - Look for "SMS simulated" vs "SMS sent successfully"

## Common Issues

### Issue 1: "SMS simulated" message
**Cause:** `TEXT_LK_API_TOKEN` not set in `.env`

**Fix:**
1. Open `backend/.env`
2. Add: `TEXT_LK_API_TOKEN=2396|Cabsm0McwWihFpWK6MXIcdDvnmvCXwTvu6aAMcIQ640a6ebd`
3. Restart server

### Issue 2: 401 Unauthorized
**Cause:** Token format incorrect or expired

**Fix:**
- Verify token in Text.lk dashboard
- Check token format: should be `2396|xxxxx...`
- Regenerate token if needed

### Issue 3: 400 Bad Request
**Cause:** API endpoint or request format incorrect

**Fix:**
- Check API URL format
- Verify phone number format (should be 94XXXXXXXXX)
- Check Text.lk API documentation for correct format

### Issue 4: No response / Network error
**Cause:** API endpoint might be wrong or network issue

**Fix:**
- Try different endpoint: `https://app.text.lk/api/http/` or `https://app.text.lk/api/http/send`
- Check internet connection
- Verify Text.lk service status

## Test SMS Manually

Run this in backend directory:
```bash
node test-sms.js
```

Make sure to update the test number in `test-sms.js` first!

## Check Backend Console

When you submit an inquiry, you should see:
- ✅ "SMS sent successfully" - SMS was sent
- ⚠️ "SMS simulated" - Token not configured
- ❌ Error messages - Check the error details

## Next Steps

1. Check backend console output when submitting inquiry
2. Share the console output with me
3. I'll help fix the specific issue

