{"id":13509508,"url":"https://github.com/danielberkompas/ex_twiml","last_synced_at":"2025-05-06T23:45:19.821Z","repository":{"id":28423382,"uuid":"31938092","full_name":"danielberkompas/ex_twiml","owner":"danielberkompas","description":"Generate TwiML with Elixir","archived":false,"fork":false,"pushed_at":"2024-04-10T01:49:47.000Z","size":94,"stargazers_count":39,"open_issues_count":0,"forks_count":14,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-27T05:38:47.147Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/danielberkompas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-10T04:19:06.000Z","updated_at":"2025-01-21T03:25:04.000Z","dependencies_parsed_at":"2024-04-10T02:48:58.214Z","dependency_job_id":"ca762abc-04d6-4d0a-8160-d9b4c5084c91","html_url":"https://github.com/danielberkompas/ex_twiml","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fex_twiml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fex_twiml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fex_twiml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fex_twiml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielberkompas","download_url":"https://codeload.github.com/danielberkompas/ex_twiml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788404,"owners_count":21804280,"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":[],"created_at":"2024-08-01T02:01:08.748Z","updated_at":"2025-05-06T23:45:19.786Z","avatar_url":"https://github.com/danielberkompas.png","language":"Elixir","funding_links":[],"categories":["Third Party APIs"],"sub_categories":[],"readme":"ExTwiml\n===================\n[![Build Status](https://danielberkompas.semaphoreci.com/badges/ex_twiml/branches/master.svg?style=shields)](https://danielberkompas.semaphoreci.com/projects/ex_twiml)\n[![Hex Version](http://img.shields.io/hexpm/v/ex_twiml.svg)](https://hex.pm/packages/ex_twiml)\n[![Inline docs](http://inch-ci.org/github/danielberkompas/ex_twiml.svg?branch=master)](http://inch-ci.org/github/danielberkompas/extwiml)\n\nGenerate TwiML for your [Twilio](http://twilio.com) integration, right inside\nElixir! Built to be used with [Telephonist](https://github.com/danielberkompas/telephonist),\nbut it can be used entirely on its own.\n\n## Installation\n\nExTwiml can be installed through mix as a hex package. First, update your\ndependencies in `mix.exs`.\n\n```elixir\ndefp deps do\n  [{:ex_twiml, \"~\u003e 2.1.3\"}]\nend\n```\n\nIf you prefer, you can depend on the latest version from Github:\n\n```elixir\ndefp deps do\n  [{:ex_twiml, github: \"danielberkompas/ex_twiml\"}]\nend\n```\n\nAdd it to your application list in `mix.exs`:\n\n```diff\ndef application do\n  [mod: {YourApp, []},\n+   applications: [:ex_twiml]]\nend\n```\n\nThen run `mix deps.get`, and ExTwiml will be installed.\n\n## Usage\n\nImport the `ExTwiml` module into your module, and then use the `twiml` macro to\ngenerate your TwiML, like so:\n\n```elixir\ndefmodule YourModule do\n  import ExTwiml\n\n  def render do\n    twiml do\n      play \"/assets/welcome.mp3\"\n      gather digits: 4, finish_on_key: \"#\" do\n        say \"\"\"\n        Please enter the last four digits of your credit card number, followed\n        by the pound sign.\n        \"\"\", voice: \"woman\"\n      end\n    end\n  end\nend\n```\n\nYou can then render the TwiML by calling `YourModule.render/0`. The output will\nbe a binary in this format:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cResponse\u003e\n  \u003cPlay\u003e/assets/welcome.mp3\u003c/Play\u003e\n  \u003cGather digits=\"4\" finishOnKey=\"#\"\u003e\n    \u003cSay voice=\"woman\"\u003e\n      Please enter the last four digits of your credit card number, followed by\n      the pound sign.\n    \u003c/Say\u003e\n  \u003c/Gather\u003e\n\u003c/Response\u003e\n```\n\nThe `twiml` macro simply returns a binary (or string), so you're not limited to\nthe pattern above. Just use `twiml` wherever you need a TwiML string.\n\n## Configuration\n\nYou can configure default options for verbs. For example, suppose you wanted all\n`\u003cSay\u003e` verbs to use the \"Alice\" voice, and all `\u003cGather\u003e` verbs to have the\nmethod \"GET\".\n\nSimply add this code to your `config/config.exs`:\n\n```elixir\nconfig :ex_twiml, :defaults,\n  say: [voice: \"alice\"],\n  gather: [method: \"GET\"]\n```\n\nThen this code:\n\n```elixir\ntwiml do\n  gather do\n    say \"Hello\"\n  end\nend\n```\n\nWill result in this TwiML:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cResponse\u003e\n  \u003cGather method=\"GET\"\u003e\n    \u003cSay voice=\"alice\"\u003eHello\u003c/Say\u003e\n  \u003c/Gather\u003e\n\u003c/Response\u003e\n```\n\nDefaults can be overridden:\n\n```elixir\ngather method: \"POST\"\nsay \"Hello\", voice: \"woman\"\n```\n\n## Supported Verbs and Nouns\nSee the [Twilio Documentation](https://www.twilio.com/docs/api/twiml) for a\ncomplete list of verbs supported by Twilio. ExTwiml has built in macros for the\nfollowing verbs and nouns:\n\n- [Say](https://www.twilio.com/docs/api/2010-04-01/twiml/say)\n- [Play](https://www.twilio.com/docs/api/2010-04-01/twiml/play)\n- [Gather](https://www.twilio.com/docs/api/2010-04-01/twiml/gather)\n- [Record](https://www.twilio.com/docs/api/2010-04-01/twiml/record)\n- [Sms](https://www.twilio.com/docs/api/2010-04-01/twiml/sms)\n- [Dial](https://www.twilio.com/docs/api/2010-04-01/twiml/dial)\n    - [Number](https://www.twilio.com/docs/api/2010-04-01/twiml/number)\n    - [Sip](https://www.twilio.com/docs/api/2010-04-01/twiml/sip)\n    - [Client](https://www.twilio.com/docs/api/2010-04-01/twiml/client)\n    - [Conference](https://www.twilio.com/docs/api/2010-04-01/twiml/conference)\n    - [Queue](https://www.twilio.com/docs/api/2010-04-01/twiml/queue)\n- [Enqueue](https://www.twilio.com/docs/api/2010-04-01/twiml/enqueue)\n- [Leave](https://www.twilio.com/docs/api/2010-04-01/twiml/leave)\n- [Hangup](https://www.twilio.com/docs/api/2010-04-01/twiml/hangup)\n- [Redirect](https://www.twilio.com/docs/api/2010-04-01/twiml/redirect)\n- [Reject](https://www.twilio.com/docs/api/2010-04-01/twiml/reject)\n- [Pause](https://www.twilio.com/docs/api/2010-04-01/twiml/pause)\n- [Message](https://www.twilio.com/docs/api/2010-04-01/twiml/message)\n    - [Body](https://www.twilio.com/docs/api/2010-04-01/twiml/body)\n    - [Media](https://www.twilio.com/docs/api/2010-04-01/twiml/media)\n- [Redirect](https://www.twilio.com/docs/api/2010-04-01/twiml/redirect)\n\nTo maximize compatibility with future versions of the TwiML spec, ExTwiml\n**does not** validate the attributes passed to the various verbs to ensure that\nthey are supported by Twilio. You'll need to do this yourself.\n\n### Unsupported Verbs?\nIf the Twilio API adds a verb and I haven't yet added support for it, you can do\ntwo things:\n\n1. Submit a PR to add it\n2. Use the `tag` macro in the meantime while the PR is reviewed\n\nThe tag macro can be used to create arbitrary XML tags in the output, like this:\n\n```elixir\ntag :custom, option_1: \"value\" do\n  tag :speak, do: \"Whatever you say, boss!\"\nend\n# =\u003e \"\u003cCustom option1=\"value\"\u003e\u003cSpeak\u003eWhatever you say, boss!\u003c/Speak\u003e\u003c/Custom\u003e\"\n```\n\n## Contributing\n\nContributions are welcome!\n\n1. Fork the repository\n2. Code up your changes\n3. Submit a PR back here with your fix.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielberkompas%2Fex_twiml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielberkompas%2Fex_twiml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielberkompas%2Fex_twiml/lists"}