ETA notifications implementation with Java - Servlets and Twilio.
- Java Development Kit version 8
- ngrok
- PostgreSQL
- A Twilio account - sign up
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 |
-
Clone this repository and
cd
into it -
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
-
Copy the sample configuration file
env.example
:cp .env.example .env
-
Edit the sample configuration file
.env
to match your configuration.See Twilio Account Settings to locate the necessary environment variables.
-
Execute the migrations.
./gradlew flywayMigrate
-
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
-
Seed the database
./gradlew dbSeed
-
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
-
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!
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
In order to test the application, you must run the database migrations.
./gradlew check
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.