Header Logo
Published on

Twilio Challenge: SmartyCall - AI Powered Competitive Trivia

Authors
  • Name
    Twitter

header image

This is a submission for the Twilio Challenge

What I Built

SmartyCall is an interactive trivia game that utilizes Twilio's Voice and SMS APIs, OpenAI's language model, and Couchbase for data storage. This application allows users to register via SMS, receive trivia questions through voice calls, and respond either via voice or text. The game maintains a leaderboard to track scores and rankings, providing a competitive edge to the trivia challenges.

System Architecture

Key Components:

  • Twilio Voice API: Handles the voice interactions, asking trivia questions and accepting verbal responses along with feedback on whether the answer was correct or not.
  • Twilio SMS API: Manages user registrations and sends updates or notifications about scores and game status.
  • OpenAI API: Generates trivia questions and processes user responses to determine correctness.
  • Couchbase Capella: Stores user data, game scores and questions are cached for uniqueness checks.

Data Flow:

  • Users register via SMS and are stored in the Couchbase database.
  • Users initiate the game via a voice call, where they receive questions generated by OpenAI.
  • All questions are cached in Couchbase and the cache is used to check for uniqueness.
  • Answers are processed and validated through OpenAI, and scores are updated in Couchbase.

Backend Setup:

  • The Node.js application serves as the backend, handling API requests and responses.
  • Express.js is used for routing, managing different endpoints for SMS and voice interactions.

Demo

Twilio and AI

In "SmartyCall," Twilio's APIs play a crucial role. The Voice API is used to deliver trivia questions to players and collect their responses through natural voice inputs. The SMS API manages user registrations and sends text updates about scores and game progress. The integration with OpenAI’s GPT-4o allows the game to generate trivia questions dynamically and evaluate responses, adding a layer of intelligence and interaction that enhances user engagement.

Source Code

You can find the source code for the game on GitHub. Feel free to clone it and modify it according to whatever you would like to build!

Additional Prize Categories

SmartyCall qualifies for the following additional prize categories in the Twilio Hackathon:

  • Twilio Times Two: This category is met as the project uses both Twilio's Voice and SMS APIs.
  • Entertaining Endeavors: The application provides an entertaining way for users to engage with trivia, making learning fun and interactive.