Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AI Powered Competitive Trivia

License

NotificationsYou must be signed in to change notification settings

hummusonrails/trivia-game

Repository files navigation

SmartyCall is an interactive trivia game that uses Node.js, Couchbase, Twilio Voice and SMS APIs, and the OpenAI API to deliver trivia questions to players via phone calls and SMS. Players can register via SMS, receive trivia questions through phone calls, and get their scores tracked in real-time.

This application was built for theTwilio Hackathon Challenge on devto.

Features

  • User registration via SMS
  • AI-generated trivia questions using OpenAI API
  • Cached trivia questions in Couchbase
  • Interactive voice-based gameplay with Twilio Voice
  • Score tracking and leaderboard via Couchbase
  • Delivery status tracking for SMS messages

Technologies Used

Prerequisites

  • Node.js and npm installed
  • Couchbase Capella account
  • Twilio account with a phone number
  • OpenAI API key

Installation

  1. Clone the repository:

    git clone https://github.com/hummusonrails/trivia-game.gitcd trivia-game
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    Create a.env file in the root directory with the following content:

    COUCHBASE_URL=couchbases://cb.<your-endpoint>.cloud.couchbase.comCOUCHBASE_USER=your-couchbase-usernameCOUCHBASE_PASSWORD=your-couchbase-passwordCOUCHBASE_BUCKET=your-couchbase-bucket-nameCOUCHBASE_BUCKET_QUESTIONS=your-couchbase-bucket-questions-nameTWILIO_ACCOUNT_SID=your-twilio-account-sidTWILIO_AUTH_TOKEN=your-twilio-auth-tokenTWILIO_PHONE_NUMBER=your-twilio-phone-numberOPENAI_API_KEY=your-openai-api-keySESSION_SECRET=your-session-secret
  4. Run the application:

    npm run start
  5. Expose your local server to the internet:Usengrok to expose your local server to the internet for Twilio webhooks.

    ngrok http 3000

Usage

Register a User via SMS

  1. Send an SMS:Text "JOIN" to your Twilio phone number to register for the game.
  2. Receive a welcome message:You will receive a welcome message and instructions on how to start the game.

Start the Game

  1. Text "JOIN" to your Twilio phone number:You will receive a message with the phone number to call to start the game.
  2. Call the provided number:You will receive a welcome message followed by a trivia question. Each unique question is cached in Couchbase to avoid repeating the same question.
  3. Answer the trivia question:Respond via voice, and you will receive feedback on whether your answer was correct. Your score will be tracked.

Check Your Score

  1. Text "LEADERBOARD" to your Twilio phone number:You will receive a message with your current score and rank on the leaderboard.

Delivery Status Callback

To get detailed delivery status for your messages, set the "Status Callback URL" in your Twilio settings to:

http://<your-ngrok-url>/callback/status

File Structure

ai-trivia-game/├── src/│   ├── controllers/│   │   ├── voiceController.js│   │   ├── smsController.js│   │   ├── callbackController.js│   ├── services/│   │   ├── openaiService.js│   │   ├── twilioService.js│   │   ├── couchbaseService.js│   ├── routes/│   │   ├── voiceRoutes.js│   │   ├── smsRoutes.js│   │   ├── callbackRoutes.js│   ├── config/│   │   ├── couchbaseConfig.js│   │   ├── twilioConfig.js│   │   ├── openaiConfig.js│   ├── app.js│   └── server.js├── .env├── package.json├── package-lock.json└── README.md

Contributing

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature-name)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin feature/your-feature-name)
  5. Create a new Pull Request

License

This project is licensed under the MIT License - see theLICENSE file for details.

Code of Conduct

Please read theCODE_OF_CONDUCT for details on the standards for collaboration within this project.

About

AI Powered Competitive Trivia

Resources

License

Code of conduct

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp