All Projects → philnash → twiml_template

philnash / twiml_template

Licence: MIT License
TwiML templates for Rails and Tilt.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to twiml template

Twilio Python
A Python module for communicating with the Twilio API and generating TwiML.
Stars: ✭ 1,536 (+9500%)
Mutual labels:  twilio, twiml
ruby-whatsapp-bots
A repo of WhatsApp bots built in Ruby
Stars: ✭ 18 (+12.5%)
Mutual labels:  sinatra, twilio
somleng
Open Source Implementation of Twilio's REST API
Stars: ✭ 33 (+106.25%)
Mutual labels:  twilio, twiml
twilio-live-interactive-video
An interactive live video app built with Twilio Live and Twilio Video
Stars: ✭ 23 (+43.75%)
Mutual labels:  twilio
timber-ruby
🌲 Great Ruby logging made easy.
Stars: ✭ 155 (+868.75%)
Mutual labels:  sinatra
mailanes
Smart E-mail Delivery System
Stars: ✭ 33 (+106.25%)
Mutual labels:  sinatra
serverless-rack
Serverless plugin to deploy Ruby Rack applications (Sinatra/Rails/Padrino/Cuba etc.) and bundle gems
Stars: ✭ 58 (+262.5%)
Mutual labels:  sinatra
dog-bathroom-button
A button for a dog to press to text their owner they need to go out
Stars: ✭ 16 (+0%)
Mutual labels:  twilio
land acknowledgement
Land Acknowledgement SMS Application
Stars: ✭ 27 (+68.75%)
Mutual labels:  twilio
raygun4ruby
The Ruby & Ruby on Rails provider for Raygun
Stars: ✭ 37 (+131.25%)
Mutual labels:  sinatra
rack-simple user agent
Rack::SimpleUserAgent is stupidly simple UA detector
Stars: ✭ 13 (-18.75%)
Mutual labels:  sinatra
microblog-verify
Microblog application from the Flask Mega-Tutorial with added two-factor authentication via the Twilio Verify API.
Stars: ✭ 27 (+68.75%)
Mutual labels:  twilio
twilio-voice
A Google Voice-like service you can run yourself with Twilio
Stars: ✭ 68 (+325%)
Mutual labels:  twilio
sample-template-nodejs
A template repository serving as the base for new Twilio sample apps
Stars: ✭ 16 (+0%)
Mutual labels:  twilio
first-twilio-video-application
A demo of Twilio Video for the Build your first Twilio Video application webinar.
Stars: ✭ 16 (+0%)
Mutual labels:  twilio
twilio mock
Mock Twilio gem for Ruby
Stars: ✭ 26 (+62.5%)
Mutual labels:  twilio
quarantine-bot
WhatsApp bot powered by Twilio API to get through the quarantine. Latest COVID19 statistics, world news, inspirational quotes and cat photos.
Stars: ✭ 24 (+50%)
Mutual labels:  twilio
books
List of all Ruby books
Stars: ✭ 49 (+206.25%)
Mutual labels:  sinatra
twilio-voice-notification-app
Reference app built in ReactJS that demonstrates how to leverage Twilio Programmable Voice and Twilio SDKs to create a voice notification system.
Stars: ✭ 21 (+31.25%)
Mutual labels:  twilio
lifebot
Use Google Sheets to log your life by texting it Emojis and pulling in data from Fitbit automatically.
Stars: ✭ 15 (-6.25%)
Mutual labels:  twilio

TwimlTemplate

TwiML templates for Tilt.

An easy way to work with TwiML for responding to Twilio webhooks in Rails or Sinatra applications using template files with a .twiml extension.

Build Status Code Climate

Example

If you create a template called hello_world.twiml with the following code:

twiml.say(message: "Hello World!")

and rendered it from an application you would get the following response:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say>Hello World!</Say>
</Response>

See Rails or Sinatra below for full instructions.

Installation

Add this line to your application's Gemfile:

gem 'twiml_template'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install twiml_template

Usage

twiml_template allows you to use a template with the extension .twiml to write TwiML. The template makes a single variable, twiml available. twiml is an instance of a TwimlTemplate::Response which unifies the twilio-ruby gem's Twilio::TwiML::VoiceResponse and Twilio::TwiML::MessagingResponse classes. This means you only need one type of template file, but you can use it for either voice or messaging responses. twiml_template passes methods through to objects of each of those classes to generate the response.

If you start writing a voice response, you can only continue writing a voice response. If you start writing a messaging response, you can only continue with a messaging response. This should never cause you a problem (you would never normally write a response with a <Say> and a <Message> in it!).

Rails

By including the twiml_template gem in your Rails project Gemfile you will be able to write TwiML templates easily.

Create a controller, like below:

class VoiceController < ApplicationController
  def index
    @name = "World"
  end
end

Add a route:

Rails.application.routes.draw do
  get 'voice' => 'voice#index'

  # Other routes...
end

And then add your TwiML view:

  twiml.say message: "Hello #{@name}"

Save the file as #{RAILS_ROOT}/app/views/voice/index.twiml.

Run the app using rails s and visit http://localhost:3000/voice and you will see:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say>Hello World!</Say>
</Response>

Sinatra

Create your application file like below:

require 'sinatra'
require 'sinatra/twiml'

helpers Sinatra::TwiML

get '/voice' do
  @name = "World!"
  twiml :voice
end

And then add your TwiML view:

  twiml.say message: "Hello #{@name}"

Save the file as #{APP_ROOT}/views/voice.twiml.

Start the app with ruby app.rb and visit http://localhost:4567/voice and you will see:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say>Hello World!</Say>
</Response>

Contributing

  1. Fork it ( https://github.com/philnash/twiml_template/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].