{"id":18111896,"url":"https://github.com/philnash/twiml_template","last_synced_at":"2025-04-14T03:34:10.313Z","repository":{"id":22785471,"uuid":"26131592","full_name":"philnash/twiml_template","owner":"philnash","description":"TwiML templates for Rails and Tilt.","archived":false,"fork":false,"pushed_at":"2022-09-15T02:34:45.000Z","size":26,"stargazers_count":17,"open_issues_count":2,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T17:36:47.918Z","etag":null,"topics":["rails","ruby","sinatra","tilt","twilio","twilio-ruby","twiml"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philnash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-03T18:07:12.000Z","updated_at":"2023-01-09T08:23:21.000Z","dependencies_parsed_at":"2022-08-21T02:10:19.478Z","dependency_job_id":null,"html_url":"https://github.com/philnash/twiml_template","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Ftwiml_template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Ftwiml_template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Ftwiml_template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philnash%2Ftwiml_template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philnash","download_url":"https://codeload.github.com/philnash/twiml_template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631691,"owners_count":21136559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rails","ruby","sinatra","tilt","twilio","twilio-ruby","twiml"],"created_at":"2024-11-01T01:08:18.143Z","updated_at":"2025-04-14T03:34:10.288Z","avatar_url":"https://github.com/philnash.png","language":"Ruby","readme":"# TwimlTemplate\n\n[TwiML](https://www.twilio.com/docs/api/twiml) templates for Tilt.\n\nAn easy way to work with TwiML for responding to [Twilio](http://twilio.com) webhooks in Rails or Sinatra applications using template files with a `.twiml` extension.\n\n[![Build Status](https://travis-ci.org/philnash/twiml_template.svg)](https://travis-ci.org/philnash/twiml_template) [![Code Climate](https://codeclimate.com/github/philnash/twiml_template/badges/gpa.svg)](https://codeclimate.com/github/philnash/twiml_template)\n\n## Example\n\nIf you create a template called `hello_world.twiml` with the following code:\n\n```ruby\ntwiml.say(message: \"Hello World!\")\n```\n\nand rendered it from an application you would get the following response:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cResponse\u003e\n  \u003cSay\u003eHello World!\u003c/Say\u003e\n\u003c/Response\u003e\n```\n\nSee [Rails](#rails) or [Sinatra](#sinatra) below for full instructions.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'twiml_template'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install twiml_template\n\n## Usage\n\n`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.\n\nIf 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 `\u003cSay\u003e` and a `\u003cMessage\u003e` in it!).\n\n### Rails\n\nBy including the `twiml_template` gem in your Rails project Gemfile you will be able to write TwiML templates easily.\n\nCreate a controller, like below:\n\n```ruby\nclass VoiceController \u003c ApplicationController\n  def index\n    @name = \"World\"\n  end\nend\n```\n\nAdd a route:\n\n```ruby\nRails.application.routes.draw do\n  get 'voice' =\u003e 'voice#index'\n\n  # Other routes...\nend\n```\n\nAnd then add your TwiML view:\n\n```ruby\n  twiml.say message: \"Hello #{@name}\"\n```\n\nSave the file as `#{RAILS_ROOT}/app/views/voice/index.twiml`.\n\nRun the app using `rails s` and visit [http://localhost:3000/voice](http://localhost:3000/voice) and you will see:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cResponse\u003e\n  \u003cSay\u003eHello World!\u003c/Say\u003e\n\u003c/Response\u003e\n```\n\n### Sinatra\n\nCreate your application file like below:\n\n```ruby\nrequire 'sinatra'\nrequire 'sinatra/twiml'\n\nhelpers Sinatra::TwiML\n\nget '/voice' do\n  @name = \"World!\"\n  twiml :voice\nend\n```\n\nAnd then add your TwiML view:\n\n```ruby\n  twiml.say message: \"Hello #{@name}\"\n```\n\nSave the file as `#{APP_ROOT}/views/voice.twiml`.\n\nStart the app with `ruby app.rb` and visit [http://localhost:4567/voice](http://localhost:4567/voice) and you will see:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cResponse\u003e\n  \u003cSay\u003eHello World!\u003c/Say\u003e\n\u003c/Response\u003e\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/philnash/twiml_template/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilnash%2Ftwiml_template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilnash%2Ftwiml_template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilnash%2Ftwiml_template/lists"}