Giter VIP home page Giter VIP logo

sixstringsin / twilio-salesforce Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twilio/twilio-salesforce

0.0 2.0 0.0 691 KB

A Salesforce/Force.com library for communicating with the Twilio REST API and generating TwiML. Need help? Post your questions to http://getsatisfaction.com/twilio or email us at [email protected]

Home Page: http://www.twilio.com/salesforce

License: MIT License

Makefile 1.08% Python 2.45% CSS 0.19% Apex 96.28%

twilio-salesforce's Introduction

Twilio Helper Library for Salesforce

Get ready to unleash the power of the Twilio cloud communications platform in Salesforce and Force.com! Soon you'll be building powerful voice and text messaging apps in Apex and Visualforce.

With this toolkit you'll be able to:

  • Make requests to Twilio's REST API
  • Control phone calls and respond to text messages in real time with TwiML
  • Embed Twilio Client in-browser calling in your Salesforce and Force.com apps

Installation

We've made it easy to get started. Just grab the code from GitHub and deploy it to your Salesforce org with the included Ant script.

Quick Install: If you do not have the existing Twilio-Salesforce library installed, you can use this unmanaged package to install: https://login.salesforce.com/packaging/installPackage.apexp?p0=04ti0000000XkE0

If you have a previous version of Twilio-Salesforce library installed, you will need to use Ant to install/update:

  1. Checkout or download the twilio-salesforce library from GitHub.

    $ git clone [email protected]:twilio/twilio-salesforce.git
  2. Install the Force.com Migration Tool plugin for Ant, if you don't already have it.

  3. Edit install/build.properties to insert your Salesforce username and password. Since you will be using the API to access Salesforce, remember to append your Security Token to your password.

  4. Open your command line to the install folder, then deploy using Ant:

    $ ant deployTwilio

Now all the library code is in your org and you're ready to start coding!

Quickstart

Getting started with the Twilio API couldn't be easier. Create a Twilio REST client to get started. For example, the following code makes a call using the Twilio REST API.

Make a Call

This sample calls the to phone number and plays music. The from number must be a verified number on your Twilio account.

// Find your Twilio API credentials at https://www.twilio.com/user/account
String account = 'ACXXXXXXXXXXXXXXXXX';
String token = 'YYYYYYYYYYYYYYYYYY';

TwilioRestClient client = new TwilioRestClient(account, token);

Map<String,String> params = new Map<String,String> {
        'To'   => '9991231234',
        'From' => '9991231234',
        'Url'  => 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient'
    };
TwilioCall call = client.getAccount().getCalls().create(params);

Send an SMS

This sample texts Hello there! to the to phone number. The from number must be a number which you have purchased from Twilio. Unlike voice calls, SMS messages cannot be sent from a verified number.

String account = 'ACXXXXXXXXXXXXXXXXX';
String token = 'YYYYYYYYYYYYYYYYYY';
TwilioRestClient client = new TwilioRestClient(account, token);

Map<String,String> params = new Map<String,String> {
        'To'   => '+12316851234',
        'From' => '+15555555555',
        'Body' => 'Hello there!'
    };
TwilioSMS sms = client.getAccount().getSMSMessages().create(params);

Generate TwiML

To control phone calls, your application needs to output TwiML. Use TwilioTwiML.Response to easily create a TwiML document.

TwilioTwiML.Response r = new TwilioTwiML.Response();
TwilioTwiML.Play p = new TwilioTwimL.Play('https://api.twilio.com/cowbell.mp3');
p.setLoop(5);
r.append(p);
System.debug(r.toXML());
<Response><Play loop="5">https://api.twilio.com/cowbell.mp3</Play><Response>

Next Steps

The full power of the Twilio API is at your fingertips. Visit the full documentation for advanced topics.

twilio-salesforce's People

Contributors

raghusagar avatar brettgerry avatar tmcmanus avatar dschach avatar alexcchan avatar andrewmbenton avatar beans0063 avatar johnsheehan avatar skimbrel avatar choppen5 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.