A Next.js application that allows users to search for hotels and make direct calls using Twilio integration with AI assistance.
- Real-time city and hotel search with auto-suggestions
- Phone number formatting based on country codes
- Direct calling integration with Twilio
- AI-powered call assistance using OpenAI
- Real-time call status monitoring
- Responsive, modern UI with Tailwind CSS
Before you begin, ensure you have met the following requirements:
- Node.js (v18.0.0 or higher)
- npm or yarn
- A Twilio account with:
- Account SID
- Auth Token
- A Twilio phone number
- An OpenAI API key
- ngrok (for local development)
- Clone the repository:
git clone [your-repo-url]
cd hotel-connect
- Install dependencies:
npm install
# or
yarn install
- Create two
.env
files:
For the Next.js app (root directory), create .env.local
:
TWILIO_ACCOUNT_SID=your_twilio_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_PHONE_NUMBER=your_twilio_phone_number
OPENAI_API_KEY=your_openai_api_key
BASE_URL=http://localhost:3000
WEBSOCKET_SERVER_URL=ws://localhost:5050/media-stream
For the Twilio WebSocket server (in twilio-server directory):
OPENAI_API_KEY=your_openai_api_key
PORT=5050
- Start the Next.js development server:
npm run dev
# or
yarn dev
- Start ngrok to create a tunnel for Twilio:
ngrok http 5050
- Update your
.env.local
with the ngrok URL:
WEBSOCKET_SERVER_URL=wss://your-ngrok-url/media-stream
- In a separate terminal, start the Twilio WebSocket server:
cd twilio-server
npm install
npm run dev
The application should now be running at http://localhost:3000
hotel-connect/
├── app/
│ ├── components/
│ │ └── HotelSearch.tsx
│ ├── api/
│ │ ├── call/
│ │ │ └── route.ts
│ │ ├── call-status/
│ │ │ └── route.ts
│ │ ├── voice-webhook/
│ │ │ └── route.ts
│ │ ├── cities/
│ │ │ └── route.ts
│ │ ├── hotels/
│ │ │ └── route.ts
│ │ └── scrape-phone/
│ │ └── route.ts
│ ├── utils/
│ │ └── phoneFormatting.ts
│ └── page.tsx
├── twilio-server/
│ ├── index.js
│ ├── package.json
│ └── .env
├── public/
├── package.json
└── .env.local
/api/cities
: Search for cities/api/hotels
: Search for hotels in a selected city/api/call
: Initiate a Twilio call/api/call-status
: Get call status/api/voice-webhook
: Handle Twilio voice webhooks/api/scrape-phone
: Fallback phone number scraping
- Sign up for a Twilio account at https://www.twilio.com
- Get your Account SID and Auth Token from the Twilio Console
- Purchase or use a test Twilio phone number
- Add the ngrok URL to your Twilio phone number's webhook configuration
- Sign up for an OpenAI account at https://openai.com
- Generate an API key
- Add the key to both
.env
files
- Install ngrok globally:
npm install -g ngrok
- Start ngrok:
ngrok http 5050
- Update your environment variables with the ngrok URL
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Twilio for their excellent voice API
- OpenAI for their AI capabilities
- OpenStreetMap for location data
For support, email [your-email] or open an issue in the repository.