All Projects → danielberkompas → Ex_twilio

danielberkompas / Ex_twilio

Licence: mit
Twilio API client for Elixir

Programming Languages

elixir
2628 projects

Labels

Projects that are alternatives of or similar to Ex twilio

Telephonist
Elixir state machines for Twilio calls
Stars: ✭ 38 (-86.62%)
Mutual labels:  twilio, hex
rbmq
Simple API for spawning RabbitMQ Producers and Consumers.
Stars: ✭ 20 (-92.96%)
Mutual labels:  hex
hexlightning
台灣人自己的黑名單機器人,更多的創意同時打造一個可以被信任的服務。
Stars: ✭ 34 (-88.03%)
Mutual labels:  hex
dj-twilio-sms
Twilio SMS Integration for Django
Stars: ✭ 15 (-94.72%)
Mutual labels:  twilio
lifebot
Use Google Sheets to log your life by texting it Emojis and pulling in data from Fitbit automatically.
Stars: ✭ 15 (-94.72%)
Mutual labels:  twilio
laravel-authy
Rinvex Authy is a simple wrapper for @authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.
Stars: ✭ 35 (-87.68%)
Mutual labels:  twilio
phone-captcha
📱 Block robocalls with captcha for phone calls
Stars: ✭ 32 (-88.73%)
Mutual labels:  twilio
Confex
Useful helper to read and use application configuration from environment variables.
Stars: ✭ 272 (-4.23%)
Mutual labels:  hex
react-programmable-chat
A React example of Twilio Programmable Chat
Stars: ✭ 29 (-89.79%)
Mutual labels:  twilio
first-twilio-video-application
A demo of Twilio Video for the Build your first Twilio Video application webinar.
Stars: ✭ 16 (-94.37%)
Mutual labels:  twilio
expublish
Automates semantic release versioning and best practices for elixir packages.
Stars: ✭ 17 (-94.01%)
Mutual labels:  hex
twilio-voice
A Google Voice-like service you can run yourself with Twilio
Stars: ✭ 68 (-76.06%)
Mutual labels:  twilio
chameleon
Chameleon Hex Package
Stars: ✭ 20 (-92.96%)
Mutual labels:  hex
elixir git hooks
🪝 Add git hooks to Elixir projects
Stars: ✭ 98 (-65.49%)
Mutual labels:  hex
Soup
☎️ Original open source call flooder using Twilio's API.
Stars: ✭ 267 (-5.99%)
Mutual labels:  twilio
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 (-92.61%)
Mutual labels:  twilio
land acknowledgement
Land Acknowledgement SMS Application
Stars: ✭ 27 (-90.49%)
Mutual labels:  twilio
elixir-queue
Queue data structure for Elixir-lang
Stars: ✭ 18 (-93.66%)
Mutual labels:  hex
Xcodecolorsense2
🍉 An Xcode source editor extension that shows hex color info
Stars: ✭ 281 (-1.06%)
Mutual labels:  hex
Culori
A comprehensive color library for JavaScript.
Stars: ✭ 271 (-4.58%)
Mutual labels:  hex

ExTwilio

Hex.pm Build Status Inline docs Deps Status

Installation

ExTwilio is currently beta software. You can install it from Hex:

def deps do
  [{:ex_twilio, "~> 0.9.0"}]
end

Or from Github:

def deps do
  [{:ex_twilio, github: "danielberkompas/ex_twilio"}]
end

and run mix deps.get. Now, list the :ex_twilio application as your application dependency:

def application do
  [applications: [:ex_twilio]]
end

Configuration

You will need to set the following configuration variables in your config/config.exs file:

use Mix.Config

config :ex_twilio, account_sid:   {:system, "TWILIO_ACCOUNT_SID"},
                   auth_token:    {:system, "TWILIO_AUTH_TOKEN"},
                   workspace_sid: {:system, "TWILIO_WORKSPACE_SID"} # optional

For security, I recommend that you use environment variables rather than hard coding your account credentials. If you don't already have an environment variable manager, you can create a .env file in your project with the following content:

export TWILIO_ACCOUNT_SID=<account sid here>
export TWILIO_AUTH_TOKEN=<auth token>
export TWILIO_WORKSPACE_SID=<workspace sid here> #optional

Then, just be sure to run source .env in your shell before compiling your project.

Multiple Environments

If you want to use different Twilio credentials for different environments, then create separate Mix configuration files for each environment. To do this, change config/config.exs to look like this:

# config/config.exs

use Mix.Config

# shared configuration for all environments here ...

import_config "#{Mix.env}.exs"

Then, create a config/#{environment_name}.exs file for each environment. You can then set the config :ex_twilio variables differently in each file.

Usage

ExTwilio comes with a module for each supported Twilio API resource. For example, the "Call" resource is accessible through the ExTwilio.Call module. Depending on what the underlying API supports, a resource module may have the following methods:

Method Description
all Eager load all of the resource items on all pages. Use with care!
stream Create a Stream of all the items. Use like any Stream.
find Find a resource given its SID.
create Create a resource.
update Update a resource.
destroy Destroy a resource.

Resource modules may contain their own custom methods. If the underlying API endpoint does not support an action, the related method will not be available on that module.

Supported Endpoints

ExTwilio currently supports the following Twilio endpoints:

Twilio's Lookup Rest API:

Twilio's TaskRouter API:

Twilio's ProgrammableChat API:

Twilio Capability Tokens:

Twilio Access Token Grants:

Example

# Get all the calls in the Call endpoint. Be warned, this will block
# until all the pages of calls have been fetched.
calls = ExTwilio.Call.all

# Create a stream of all the calls
stream = ExTwilio.Call.stream

# Lazily filter calls by duration, then map to get only their SIDs
stream
|> Stream.filter(fn(call) -> call.duration > 120 end)
|> Stream.map(fn(call) -> call.sid end)
|> Enum.into([]) # Only here does any work happen.
# => ["CAc14d7...", "CA649ea861..."]

# Find a call
{:ok, call} = ExTwilio.Call.find("CA13a9c7f80c6f3761fabae43242b5b6c6")
inspect(call)
# %ExTwilio.Call{
#   account_sid: "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
#   answered_by: nil, caller_name: "",
#   date_created: "Sat, 14 Mar 2015 14:27:38 +0000",
#   date_updated: "Sat, 14 Mar 2015 14:28:35 +0000",
#   direction: "outbound-api",
#   duration: "52",
#   end_time: "Sat, 14 Mar 2015 14:28:35 +0000",
#   forwarded_from: nil,
#   from: "+1xxxxxxxxxx",
#   parent_call_sid: nil,
#   phone_number_sid: "",
#   price: "-0.01500",
#   price_unit: "USD",
#   sid: "CA13a9c7f80c6f3761fabae43242b5b6c6",
#   start_time: "Sat, 14 Mar 2015 14:27:43 +0000",
#   status: "completed",
#   to: "+1xxxxxxxxxx",
#   uri: "/2010-04-01/Accounts/ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/Calls/CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.json"
# }

# Update a call
call = ExTwilio.Call.update(call, status: "canceled")

# Get a call's recordings. This pattern is repeated wherever you are
# getting a nested resource.
recordings = ExTwilio.Recording.all(call: call.sid)

# Destroy a call
ExTwilio.Call.destroy(call)

For more in-depth documentation, see the generated docs for each module.

Making and Receiving Calls

See the CALLING_TUTORIAL.md file for instructions on making and receiving calls from the browser with ExTwilio.

Sending SMS messages

Please look at ExTwilio.Message

Contributing

See the CONTRIBUTING.md file for contribution guidelines.

License

ExTwilio is licensed under the MIT license. For more details, see the LICENSE file at the root of the repository. It depends on Elixir, which is under the Apache 2 license.

TwilioTM is trademark of Twilio, Inc.

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].