This is a GitHub template for creating other Twilio sample/template apps. It contains a variety of features that should ideally be included in every Twilio sample app. You can use GitHub's repository template functionality to create a copy of this.
Implementations in other languages:
.NET | Java | Python | PHP | NodeJS |
---|---|---|---|---|
TBD | TBD | TBD | TBD | Done |
This is only a barebones Ruby on Rails application. Whenever, possible we should be using this. However, if you are using another framework like Sinatra that comes with their own standardized application structure, you should try to merge these by using the same README
structure and test coverage, configuration etc. as this project.
- Ruby on rails framework version 6
- Node.js for serving frontend assets with webpack
- User interface to send SMS with bootstrap.
- Unit tests using
Rspec
- End to End UI testing using Capybara
- Automated CI testing using GitHub Actions
- Linting and formatting using Rubocop
- Project specific environment variables using
.env
files anddotenv-rails
by comparing.env.example
and.env
. - One click deploy buttons for Heroku, Glitch and now.sh
- Pre-commit hooks using Overcommit to ensure standardized code style and formatting.
- Create a copy using GitHub's repository template functionality
- Update the
README.md
andGemfile
with the respective values. - Build your app as necessary while making sure the tests pass.
- Publish your app to GitHub
- Ruby version 3.0.x or later.
- Bundler
- Node.js version 14.15.4 - Rails 6 now uses webpack to serve frontend assets, so it needs Node to install it.
- 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 |
Before diving into the setup, it is RECOMMENDED to use Ruby with a version manager such as rbenv
or asdf
. This is specially important for MacOS users since OSX comes with a preinstalled Ruby version (usually an older version than the current) which may not be compatible with the new Rails 6 and it's generally better not to mess with system packages.
After the above requirements have been met:
- Clone this repository and
cd
into it
git clone [email protected]:twilio-labs/sample-template-rails.git
cd sample-template-rails
- Install gem dependencies
bundle install
- Install Node dependencies:
npm install
- Set your environment variables
cp .env.example .env
See Twilio Account Settings to locate the necessary environment variables.
- Configure pre-commit hooks
bundle exec overcommit --install
- Run the application
bundle exec rails s
Alternatively, you can use this command to start the server in development mode. It will reload whenever you change any files.
bundle exec rails s -e development
- Navigate to http://localhost:3000
That's it!
You can run the tests locally by typing:
bundle exec rspec
Additionally to trying out this application locally, you can deploy it to a variety of host services. Here is a small selection of them.
Please be aware that some of these might charge you for the usage or might make the source code for this application visible to the public. When in doubt research the respective hosting service first.
Service | |
---|---|
Heroku |
Some notes:
- Heroku does not support SQLite, so if you want to deploy to Heroku you need to make the necessary changes on the project to use Postgres instead of SQLite.
- GitHub's repository template functionality
This template is open source and welcomes contributions. All contributions are subject to our Code of Conduct.
No warranty expressed or implied. Software is as is.