Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

TwilioDevEd/eta-notifications-servlets

Repository files navigation

ETA Notifications for Java - Servlets

Java Servlet CI

ETA notifications implementation with Java - Servlets and Twilio.

Setup

Requirements

Twilio Account Settings

This application should give you a ready-made starting point for writing your own appointment reminder application. Before we begin, we need to collect all the config values we need to run the application:

Config Value Description
Account Sid Your primary Twilio account identifier - find this in the Console.
Auth Token Used to authenticate - just like the above, you'll find this here.
Phone number A Twilio phone number in E.164 format - you can get one here

Local Development

  1. Clone this repository and cd into it

  2. Create the database

    The application uses PostgreSQL as the persistence layer. If you don't have it already, you should install it. The easiest way is by using Postgres.app.

    createdb eta_notifications
    
  3. Copy the sample configuration file env.example:

    cp .env.example .env
  4. Edit the sample configuration file .env to match your configuration.

    See Twilio Account Settings to locate the necessary environment variables.

  5. Execute the migrations.

    ./gradlew flywayMigrate
  6. Modify seed data

    We have provided an example of name and phone number in the seed data. In order for the application to send sms notifications, you must edit this seed data providing a real phone number where you want the sms notifications to be received.

    Modify the DBSeeder.java file

  7. Seed the database

    ./gradlew dbSeed
  8. Expose your application to the wider internet using ngrok

    You can click here for more details. This step is important because the application won't work as expected if you run it through localhost.

    ngrok http 8080
  9. Run the application

    ./gradlew appRun

    Once Ngrok is running, open up your browser and go to your ngrok URL. It will look like this: http://<your_subdomain>.ngrok.io

    That's it!

Expose the Application to the Wider Internet

If you want your application to be accessible from the internet, you can either forward the necessary ports in your router, or use a tool like ngrok that will expose your local host to the internet.

You can read this blog post for more details on how to use ngrok, but if you are using version 2.x, exposing a specific port should be easily done with the following command:

ngrok http 8080

Run the tests

In order to test the application, you must run the database migrations.

./gradlew check

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.