Appirio's Tech Blog

Wednesday, November 25, 2009

Force.com Demo with Twilio

Jeff Douglas

During Dreamforce 09 Kyle Roche and I participated in the Developer Hackathon. We hacked-up an application using Force.com and Twilio for inbound and outbound calling. We were only allotted two hours so we were not able to finish off the application during the hackathon.

Here is the final demo with all of the major working pieces. The application has two major parts:
  • Kyle's part (much harder and more glamourous) uses the Twilioforce toolkit to make outbound calls from a contact in Salesforce. The user clicks the contact's phone number and the Force.com platform makes an outbound call to the contact using Twilio. Once the contact picks up Twilio then calls the phone number on the user's record and connects the two calls together.
  • My part of the application uses Twilio with a Sites application for inbound calling. The person calls a phone number that reads a script generated from a Force.com Sites page. The greeting welcomes the person, plays an MP3 and then prompts them to records a message. After they are finished with the message it posts the results to another Sites page with attaches the message to the contact's record in Salesforce. It looks up the contact record based upon the incoming phone number.

Here's a video of the final application.

video

Monday, November 16, 2009

Appirio Dreamforce Coding Scavenger Hunt

We are excited to announce the Appirio Dreamforce Coding Scavenger Hunt. You do not even have to be attending Dreamforce to win! There are three brainteasers for you to solve. All you need is a Salesforce Developer org and some APEX skills. As you solve each brainteaser, a key will be generated for you. Solve all three brainteasers, get all three keys and you can win! The first three people to solve all three brainteasers will win $500 dollars each. We will also be randomly selecting two competitors who completed the brainteasers to receive a copy of Jason Ouellette’s new book, Development with the Force.com Platform.

Each brainteaser should not take too much time, since we do want you to enjoy Dreamforce. The first brainteaser is very easy! All you have to do is register for the coding challenge here: http://www.appirio.com/challenge. Just enter your email address and name to generate the first key.

The second brainteaser will require you to call an external webservice from Salesforce. The WSDL for the webservice can be found here: http://dev.appirio.net/brainteaser/PHPWebService/nusoap/server.php?wsdl

For the third brainteaser, you will code an inbound email handler in APEX. Once you have written your email handler, go to this page and enter the email handler's email address and your email address to receive your third key.

When you have all your keys, go to this page and enter your email address and all three keys. If they match, you have an opportunity to win a prize! All solutions must be in by 9 AM PT on Friday 11/20.

Good luck!

Friday, November 13, 2009

Salesforce.com Robot for Google Wave


Jeff Douglas

This is a small Google Wave robot that interacts with Salesforce.com to display contacts, accounts and opportunities. The robot is currently a work in progress as I've been busy with other work projects, getting ready for Dreamforce 09 and working on a Twilioforce demo. If you have any ideas for future functionality or comments, please let me know.

The robot is currently hooked up to my developer account but you are free to add it to a wave and try out the functionality for yourself. Simply follow the video and add the robot (sfdcwavebot@appspot.com) to your contacts.

You can watch this at full size at YouTube.


Wednesday, November 11, 2009

Twilioforce - Click to Call Demo

To help you with your entries for the Twilio Developer Challenge that runs until Dreamforce I've put together a quick demo of a Click To Call function for Salesforce CRM. Basically, the demo adds a link to the Contact Page Layout and will connect your phone to the Contact's Phone with a simple click.

First, download the Twilioforce library. It's a good set of starter code. I had to fix a few defects to get this demo working, so the SVN trunk has been updated with the latest code. In addition to the code, you're going to need a few custom fields to get this to run. I created an unmanaged package to make that easier.

Before you get started, create a Force.com Sites entry for the Visualforce Page called TwilioDialer. Add the controller and the Twilioforce classes to the public access list.

Take a look at the controller class before we fill in the configuration data. We're using the TwilioRestClient and TwilioRestResponse classes from the Twilioforce library to make our calls a bit more efficiently.

public PageReference ClickToCallAction() {
TwilioRestClient client = new TwilioRestClient(CONFIG.AccountSID, CONFIG.AuthToken, null);
Map params = new Map();
params.put('Caller', CONFIG.OutGoingCallerID);
params.put('Called', TwilioTarget);
params.put('Url', CONFIG.ClickToCallURL + '?Called=' + EncodingUtil.urlEncode(contact.phone, 'UTF-8'));

TwilioRestResponse response;
try {
response = client.request('/'+CONFIG.APIVERSION+'/Accounts/'+CONFIG.AccountSID+'/Calls', 'POST', params);
ReturnCode = 'Called Placed: Connecting ' + TwilioTarget + ' with ' + contact.Phone;
return null;
} catch (Exception e) {
ReturnCode = 'ERROR: ' + e;
return null;
}
}

1) Click on the TwilioConfig tab and create a new record. (The demo has a LIMIT 1 query so you can only have a single working config record).
2) Enter your Twilio developer info. Add an OutGoing Caller ID number that Twilio has validated.
3) Enter the URL for the Force.com Sites entry you created above.
4) Go to your User record and add your preferred phone number for Twilio calls

The package has a new page layout for Contact. If everything was done correctly you should see something that resembles the following illustration:

Clicking on the number will kick off the following events:
1) Make a REST call to Twilio's /Calls method requesting an outbound call to the phone number you entered on your User account record. (Sending the Force.com Sites URL for callback)
2) Twilio places the call (and greets you w/ the demo script if you haven't set up your paid account yet) and fetches the TwiML in the Force.com Sites Page.
3) The <dial> element is read and the Contact's Phone (which was passed in the parameter string) is dialed from your phone.

Hopefully, this will give you a headstart on your developer challenge application. Good luck and let me know if you have any questions.


Tuesday, November 10, 2009

Twilioforce - Autoinstall Unmanaged Package

Last week we posted about the Twilio developer challenge for Force.com. We just updated the Twilioforce code share project with an install URL for an unmanaged package. If you wanted to participate but didn't want to move the code yourself via SVN, here's your chance to get started. Just click on the install link, login to your Force.com Development Org and you're ready to go... Let me know if you have any questions.


Unmanaged Package Installer (incase you are too excited to find it on code share)


Tuesday, November 3, 2009

Twilioforce - A Twilio library for Force.com

Yesterday, we published an open source APEX library that implements Twilio's REST API. (Thanks to Aslam Bari for the huge contributions to this project). Twilio is an on-demand IVR platform that's provides a simple API for companies to build scalable applications that make and receive phone calls. With Dreamforce right around the corner, Twilio and Appirio are sponsoring a developer's contest around Twilio on the Force.com platform. To help you get started, I'm going to walk you through setting up the helper library in a Force.com Development Org.

Obviously, a prerequisite is having a development org. If you don't have one, you can get one for free here. In addition, you're going to need an SVN client in your Force.com IDE (Eclipse).

Open Eclipse in the SVN Repository Exploring perspective. Add a new Repository Location (right click, New -> Repository Location) and enter the Location's URL as http://twilioforce.googlecode.com/svn/trunk. You will see a folder structure like the one to the left after you're connected. Right click the src directory and choose Export. Choose a location to export the source files click OK. Switch back to the Force.com perspective and open the project for your Force.com Developer's org. Drag the contents of the /classes, /components, and /pages directories from your export into their respective directories in the Force.com project. Because this is a development org (same for Sandbox), and we don't need APEX code coverage we're able to just drag and drop the new source files to install them in the org. The auto-refresh capabilities of the Force.com IDE will deploy the files to your org in the background.

There's a few key files to focus on while you're getting started.

TwilioRestExample.cls -> APEX Class demonstrating the REST API. Don't forget to add your Twilio AccountSID and AuthToken before trying to run the example. (Sign up for free if you haven't already)

TestTwilioTags.page -> Visualforce page demonstrating the TwiML Visualforce Components. Twilio fetches TwiML from your site to drive the voice responses and instructions. Because these files need to be publicly available to Twilio, it requires you enable Force.com Sites.

The contest is scheduled to run until Dreamforce. Over the next week we'll be posting examples and tutorials on how to use the library and extend the power of the Force.com platform with Twilio to bring voice to your applications! Here's a few ideas to get things moving...

  • Application that mimics Google Voice for Salesforce CRM (click to call, store user's preferred number on User record)
  • Case Management follow up (click to call)
  • Call in campaigns (leads call in, submit info, links to Salesforce Campaign)

If you have any questions, please feel free to comment here or reach out. Appirio and Twilio look forward to seeing your submissions.


Monday, November 2, 2009

Making Force.com Accessible for More Developers

Jason Ouellette, Chief Architect

Building applications on Force.com has been a rewarding activity for me, as far as programming goes. ;-) I enjoy working at the high level of abstraction provided by the platform. Its homogeneous, single-vendor elegance is a refreshing change from open-source gluework. I've seen Force.com advance substantially and quickly, getting the chance to work with technologies like Apex and Visualforce before their release.

This is partly what inspired me to write, Development with the Force.com Platform (published by Addison-Wesley Professional; part of the Developer's Library series). The book is geared toward existing developers who want an all-in-one guide to getting started building applications with Force.com (available with online preview at Amazon and Dreamforce). In this blog and in my full-time job working on Appirio's Professional Services Enterprise(PS Enterprise) product, we go deep on specific areas of the platform. In contrast the book is more of a survey course to help readers get broad exposure to the major areas of Force.com.

As we built PS Enterprise, I discovered first-hand how much faster I could build large-scale functionality using Force.com than other platforms I've worked with over the years. In addition, it was very cool to see new capabilities being added all the time without the headache of worrying about how upgrades will impact existing code (and loved being able to package all the code samples from the book into a single AppExchange listing). My hope is that the book will expose a larger community of developers to the benefits of Force.com's in an organized, hands-on way.

Myself, many of the authors on this blog, and host of other Appirio developers will be at Dreamforce. We'd love to exchange tips and tricks, combine forces on feature requests and maybe even build something together! Also look forward to discussing the new Force.com announcements coming at Dreamforce. Find me after the Day 1 keynote!

Jason
 
2006-2010 Appirio Inc. All rights reserved.
Appirio.com | Support | Resource Center | Contact | Careers | Privacy Policy