Skip to content

dhruvb26/t3twilio

Repository files navigation

project-logo

t3twilio

Empowering seamless communication, one code line at a time.

license repo-top-language repo-language-count

Overview

The t3twilio project integrates Twilios communication capabilities, enabling users to set call reminders through the Notion interface.


Demo

compressed_video.mp4

Features

Feature Description
⚙️ Architecture The project has a modular architecture leveraging Next.js for frontend, FastAPI and Python backend for server-side logic. It uses Twilio for SMS/voice and integrates with Notion API for task management. Environment variables are managed for configuration flexibility.
🔩 Code Quality The codebase follows TypeScript for type safety, ESLint for linting, and Prettier for code formatting. It maintains consistent coding styles across components and enforces best practices.
📄 Documentation The repository contains detailed inline comments, configuration files, and README documentation. It explains setup instructions, code structure, and functionality to onboard developers effectively.
🔌 Integrations Key integrations include Twilio, Notion API, and Cloudflare AI Workers API.
🧩 Modularity The codebase is structured into reusable components and utilities for enhanced maintainability. It separates concerns between frontend and backend, enabling easy scalability and extension of features.

Modules

src.app._utils
File Summary
twilioHelpers.ts Facilitates automated call initiation and scheduling follow-up actions via Twilio API. Integrates with Node.js scheduler and Axios for API calls. Key features include dynamic call content and scheduled follow-up tasks based on specified contact information. Also includes helper function that handles email reminders.
src.app.privacy
File Summary
page.tsx Defines PrivacyPage component rendering a minimal UI for the privacy page. Displays a centered flex container with default styling, serving as a key visual element within the applications interface.
src.app.terms
File Summary
page.tsx Defines a React component rendering the TermsPage view, adding a white background with black text and centering content vertically and horizontally on the screen.
src.app.actions
File Summary
index.ts Handles authentication callback by fetching Notion API, saving credentials to the database, and returning response status.
src.app.callback
File Summary
page.tsx Enables authentication callback handling with message display and loading animation, enhancing user experience in the React-based app. Uses authCallback to process authentication code, updating message accordingly.
api.gather
File Summary
route.ts Handles POST requests, parsing and processing Twilio voice responses to update task status. Parses request body, checks user input, sends status update request, and returns XML response.
api.get-task
File Summary
route.ts Retrieves task details from the database based on the bot_id, then queries Notion API to fetch specific information. Subsequently, initiates a job by sending a POST request with the retrieved data.
api.schedule-task
File Summary
route.ts Defines voice interaction for scheduling tasks via Twilio, utilizing NGROK for API connection. Generates a response prompting users to speak task details, followed by processing and returning XML response for server communication.
api.add-task
File Summary
route.ts Handles adding a task via AI text analysis, sending extracted details to a database, and responding with TwiML message via Twilio API. Parses request body, runs AI model, and extracts task information for storage.
api.initiate-job
File Summary
route.ts Initiates job scheduling and AI processing for cloud-based reminders. Parses time data, triggers calls, and sends reminder messages. Handles API requests, utilizing environment variables for secure authentication.
api.follow-up
File Summary
route.ts Implements follow-up call initiation with Twilio, prompting user input through speech, capturing response, and redirecting. Key functions include setting up the call, defining user prompts, and handling responses, enhancing user engagement and interactivity.
src.server.python_backend
File Summary
main.py Enables updating task status and adding tasks in Notion database via FastAPI routes. Utilizes Notion API for CRUD operations and handles errors gracefully. Supports dynamic task properties and authentication through environment variables.
src.server.db
File Summary
schema.ts Defines a database schema for tokens in t3twilio, using Drizzle ORMs multi-project schema feature. It includes fields for bot ID, access token, user ID, template ID, workspace ID, and creation timestamp with timezone.
index.ts Establishes database connection caching for development to improve Hot Module Replacement. Initializes a database connection with schema and environment setup using drizzle-orm/postgres-js and postgres libraries.

Getting Started

Checkout .env.example file for API keys.

Installation

From source

  1. Clone the t3twilio repository:
$ git clone https://github.com/dhruvbansal26/t3twilio
  1. Change to the project directory:
$ cd t3twilio
  1. Install the dependencies:
$ pnpm install

Usage

From src

Run t3twilio using the commands below:

$ pnpm dev
$ ngrok http --domain=anemone-central-aardvark.ngrok-free.app 3000

From src/server/python_backend

$ uvicorn main:app --reload --port 8080

Project Roadmap

This is to be implemented as we progress the development of the integration.

  • Implement SMS & WhatsApp reminder capabilities.
  • Allow user to choose frequency of the reminder.
  • Have an end date for the reminder automation.

Contributing

Contributions are welcome! Here are several ways you can contribute:

Contributing Guidelines
  1. Fork the Repository: Start by forking the project repository to your github account.
  2. Clone Locally: Clone the forked repository to your local machine using a git client.
    git clone https://github.com/dhruvbansal26/t3twilio
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to github: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
  8. Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
Contributor Graph

About

Source code for the Twilio challenge at dev.to

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •