Archive for the ‘Programming’ Category

Want to build SMS-only apps? Check out SMSified.com and its REST web API…

Wednesday, May 18th, 2011

Smsified LogoWould you like to build applications that only use inbound or outbound SMS? i.e. no voice, IM, web or social channels… just text messaging?

If so, check out our new service -> SMSified.com

SMSified has a super simple REST API that lets you easily send and receive SMS messages using whatever programming language you already use… assuming that language can make HTTP connections. All for just 1 cent per message within the U.S.

The cool part for developers using other Voxeo platforms – you can use your same login credentials. So if you use Evolution or Tropo, you can just go over to SMSified.com and login there with the same username and password.

We’ve spent some good time putting together a solid set of documentation and sample apps with an overview and sections on sending, receiving and reporting. We’re also posting more into to the SMSified blog, complete with videos and screencasts showing you what to do. We’ll be publishing more info to that blog, too, as SMSified moves through its beta stage. One way to stay up on what’s happening with SMSified is to follow the @smsified Twitter account. Don’t forget to check out the FAQ, too!

We’ve seen a great amount of interest in an SMS-only option for building apps and so we’re pleased to launch SMSified to meet that demand. Now we’re looking forward to seeing what you all build with it!

P.S. And obviously if you want to work with more than just SMS, we have Evolution and Tropo to fit your needs!


Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


Click To Dial: a converged application on Voxeo Prism

Saturday, March 19th, 2011

Voxeo Prism is a converged application platform where you can mingle Web (HTTP) functionality with real-time communication (SIP or XMPP) functionality in a single programming model and application.

A classic example of converged application is Click-To-Dial, where the user can enter two telephone numbers in a web page and the web application calls each phone and connect them together.

In this blog, I will show how to build a simple Click-To-Dial application on Voxeo Prism that can connect two SIP softphones together.

Voxeo Prism supports both Java Servlet 2.5 API and JSP 2.1. It also supports SIP Servlet 1.1 API. So I built this application using JSP and SIP Servlet. Here is how the application, a.k.a. WAR, looks like.

Tutorial.4
   |-- WEB-INF
   |         |-- sip.xml
   |         |-- web.xml
   |         |-- xmpp.xml
   |         |-- sipmethod-application.xml
   |         |-- classes
   |                  |-- com/voxeo/prism/tutorial/four/Call.class
   |                  |-- com/voxeo/prism/tutorial/four/ClickToDialServlet.class
   |-- call.jsp
   |-- index.jsp
   |-- status.jsp
   |-- terminate.jsp
   |-- phone.jpg

Once the application is deployed on Voxeo Prism, go to http://localhost:8080/Tutorial.4 to open home page (index.jsp). It will look like the following.

Once you enter two reachable SIP addresses, e.g. sip:john@somedomain.com and sip:doe@otherdomain.com, and click the Call button. The call.jsp will be invoked to make the call to sip:john@somedomain.com and sip:doe@otherdomain.com respectively and join them together when both have answered.

The following diagram shows how the JSPs, Java objects, and SIP servlet interact with each other.

The logic of making outbound calls  are in the Call.call() method, as shown below. “_factory” is the SipFactory object. “_left” and “_right” are the URIs submitted from the index.jsp. “_servlet” is the name of the ClickToDialServlet defined in its annotation or deployment descriptor. By setting the servlet as  the handler of the session, the servlet will receive all messages for that session.

      _inviteL = _factory.createRequest(_session, "INVITE", _left, _right);
      _inviteR = _factory.createRequest(_session, "INVITE", _right, _left);
      _inviteL.setRequestURI(_right);
      _inviteR.setRequestURI(_left);
      _inviteL.getSession().setHandler(_servlet);
      _inviteL.getSession().setAttribute(Call.class.getName(), this);
      _inviteR.getSession().setHandler(_servlet);
      _inviteR.getSession().setAttribute(Call.class.getName(), this);
      _inviteL.send();
      _inviteR.send();

Once both phones have responded with 2xx answers, Call.connect() will generate ACK for each phone with the SDP from the other phone. If one of the phones returns an error response, the call is terminated. Here is the logic in Call.connect() method.

  synchronized void connect(SipServletResponse response) {
    SipServletResponse otherResponse = null;
    int code = response.getStatus();

    if (code < 200) {
      return;
    }

    if (_inviteL.getSession().equals(response.getSession())) {
      _responseL = response;
      otherResponse = _responseR;
    }
    else if (_inviteR.getSession().equals(response.getSession())) {
      _responseR = response;
      otherResponse = _responseL;
    }

    //TODO: handle 3xx for redirection
    if(code >= 300) {
      terminate();
      return;
    }

    if (otherResponse != null) {
      try {
        if (response.getStatus() >= 200 && response.getStatus() < 300 && otherResponse.getStatus() >= 200 && otherResponse.getStatus() < 300) {
          SipServletRequest ack = response.createAck();
          ack.setContent(otherResponse.getRawContent(), otherResponse.getContentType());
          SipServletRequest otherAck = otherResponse.createAck();
          otherAck.setContent(response.getRawContent(), response.getContentType());
          ack.send();
          otherAck.send();
          _state = State.CONNECTED;
        }
        // container automatically sends ACK in other cases.
      }
      catch (Exception e) {
        terminate();
      }
    }
  }

When the call is terminated, we have to send either CANCEL or BYE to each telephone. Based on RFC 3261, CANCEL should be sent before receiving the final response. The follow is the code to terminate the call to one telephone.

  private void terminate(SipServletRequest invite, SipServletResponse response) {
    try {
      if (invite != null) {
        if (invite.isCommitted()) {
          if (response == null) {
            invite.createCancel().send();
          }
          else {
            invite.getSession().createRequest("BYE").send();
          }
        }
      }
    }
    catch (Exception e) {
      // nothing we can do at this point
    }
  }

To try it out, download and deploy the application to <prism>/apps. Open the home page at http://localhost:8080/Tutorial.4. Make sure you type in valid and reachable SIP addresses. By default, PSTN telephone number won’t work unless VoIP gateway or ENUM are configured, which I will show you in the future blog.


Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


The Simplest Application on Voxeo Prism

Wednesday, January 26th, 2011

This is the simplest application on Voxeo Prism.

The content of the application is like the following

myapp
  |-- WEB-INF

That’s it!

Simply copying the myapp.war to <prism>/apps directory. The container will automatically detect that and load it up. When it loads myapp up, it will unpack the WAR into <prism>/apps/myapp directory.

Of course, this simplest application doesn’t do anything. Since Voxeo Prism is a converged SIP application server, it can handle both SIP and HTTP. The easiest way to make this application do something is to add an index.html page, as the following.

myapp
  |-- WEB-INF
  |-- index.html

You can simply create an index.html with your favorite text editor and copy it under <prism>/apps/myapp directory.

Here is what I put in my index.html

Hello, welcome to My Application!

And here is what I will see when I open http://localhost:8080/myapp

Try it out.


Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


Use Phono with a CCXML App to Call A Phone Number From Your Web Browser

Thursday, October 28th, 2010

Phono - call usIf you look over at the top of the first sidebar of this blog, you’ll now see a “Call Us!” heading, some text and then a “Call” button. If you press that button, very soon you’ll be connected to our Voxeo Sales Team down in our Orlando office … simply using the microphone and speakers on your computer!

This is the magic of Phono!

As I showed in the previous post and video, using Phono with an application running in Voxeo’s Prophecy Hosting environment is as simple as finding the “application id” on the “Contact Methods” tab of your app… and then inserting the appropriate JavaScript into a web page to create a Phono object.

Now.. what if you want to have a button on your website that simply connects the caller to a phone number?

Connecting to a Phone Number – The Simple Way

The previous example showed how to connect it to an application of some type… but what about a phone number? You can simply use the Phono sample apps on phono.com. In fact, if you take the JavaScript code from the last post and just change this:

                  this.phone.dial("app:9991476142");

by replacing “app:….” with a phone number:

                  this.phone.dial("4074181800");

that simple button will call out to that phone number using the default Phono configuration.

This works great – but calls via the sample app are limited to a max of 10 minutes and there is also an introductory and final audio message. What if you want to make it so someone can connect and talk for any amount of time?

To do that, you need to create an application on one of our platforms (Prophecy Hosting (Evolution) or Tropo) that will transfer a call to the target phone number.

Connecting to a Phone Number – The CCXML Way

For this app to transfer a call, I chose to use the W3C industry standard Call Control XML (CCXML) running in Prophecy Hosting. The app does three things:

  1. Accepts an incoming call (which will be coming in from Phono)
  2. Makes an outbound call to a phone number (in this case Voxeo Sales)
  3. Joins the two calls together in a conference.

Now, for this to work for you, you need to:

  1. Have an account on our Evolution developer portal. If you don’t already have one, you can create an account for free.
  2. Have “outbound dialing privileges” enabled for your account. Because of potential malicious use, we don’t enable outbound dialing by default – but we freely give it out if you contact our support team, either by raising a support ticket inside your Evolution account or by simply emailing support@voxeo.com.

Once both of those are true, you can get started. Inside your Evolution account, you’ll first need to go into the “Files, Logs & Reports” area and create a new file under “www” that contains this CCXML – (replacing the phone number with YOUR target phone number):

NOTE: if you move your mouse to the upper right corner of this code listing there is an icon to copy the code to your clipboard. Also note that this code is blatantly copied from the “join” documentation page


<?xml version="1.0" encoding="UTF-8"?> 
<ccxml xmlns="http://www.w3.org/2002/09/ccxml" version="1.0"> 
  <var name="inboundID"/> 
  <var name="outboundID"/> 
  <var name="initState" expr="'state1'" /> 

  <eventprocessor statevariable="initState"> 
    <transition state="state1" event="connection.alerting"> 
      <log expr="'*** INBOUND CONNECTION ALERTING ***'"/> 
      <assign name="inboundID" expr="event$.connectionid" /> 
      <accept connectionid="inboundID" /> 
      <assign name="initState" expr="'state2'"/> 
    </transition> 

    <transition state="state2" event="connection.connected"> 
      <assign name="initState" expr="'state3'"/> 
      <log expr="'*** CONNECTION.CONNECTED: INBOUND ***'"/> 
      <!-- 4079651112 is Voxeo Sales line -->
      <createcall dest="'tel:4079651112'" callerid="'1112223333'" connectionid="outboundID" timeout="'30s'"/> 
    </transition> 

    <transition state="state3" event="connection.progressing"> 
      <log expr="'*** CONNECTION.PROGRESSING ***'"/>  
      <assign name="initState" expr="'state4'"/> 
    </transition> 

    <transition state="state4" event="connection.connected"> 
      <assign name="initState" expr="'state5'"/> 
      <log expr="'*** CONNECTION.CONNECTED: INBOUND ***'"/>  
      <join id1="inboundID" id2="outboundID" duplex="'full'"/> 
    </transition> 

    <transition state="state5" event="conference.joined"> 
      <log expr="'*** CONFERENCE JOINED: INBOUND LEG TO OUTBOUND LEG ***'"/>  
    </transition> 

    <transition event="connection.disconnected"> 
      <log expr="'*** CONNECTION.DISCONNECTED ***'"/>  
      <exit/> 
    </transition> 
  </eventprocessor> 
</ccxml>

After you’ve saved that file, you’ll go over into your Application Manager, create a new “Prophecy 9 – CCXML” application and map that application to your newly created file.

You can then look on the “Contact Methods” tab to find the application ID (“app:numbers“) that you can use with Phono. You can also add a phone number and call the application directly (or use Skype or SIP) to test that the application rings through to your target phone number.

Embedding Phono On A Web Page

Once you have the application running and it calls through correctly, you just need to create a Phono object on your web page. You could use that really basic example I gave in the last post – or much better – check out the examples on Phono.com.

Or… you could use one of the tools that are already emerging to integrate Phono with websites. In my particular case I’m using a very cool WordPress plugin that I’ll be writing about very soon!

However you embed the Phono code, you just need to supply the application ID of your CCXML app and you can start connecting your visitors to your phone number right away!


Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


ReadWriteHack – a new site for developer info

Saturday, September 4th, 2010

readwritehack.jpgAs I’ve long been a fan of ReadWriteWeb, I was pleased to see that this past week they launched “ReadWriteHack“, a new “channel” focused on developers. It’s available at:

http://www.readwriteweb.com/hack/

As their intro says:

Our Channel ReadWriteHack, sponsored by the Intel Atom Developer Program, is a resource and guide for developers. ReadWriteHack will outline best practices for designing and developing applications. We will also provide examples of hacks and how they work, to inspire you and show you what’s possible.

It’s great to see RWW adding a focus on developers, and it’s certainly joined my list of sites to regularly follow. Looking forward to seeing what they write about!


Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


Anonymous Pro and Inconsolata – two free fixed-width fonts for programmers

Thursday, September 2nd, 2010

This has absolutely nothing to with “Voxeo” development tools, per se, but I thought it might be of interest to any of you out there who edit code in a text editor.  Adam Kalsey in our Voxeo Labs team recently pointed out this nice font, Anonymous Pro, that is a fixed-width sans-serif font specifically designed for coding:

AnonymousPro, a fixed-width font for coders

I’m admittedly a sucker for anything related to typography, so I did have to check it out.  It’s a set of TrueType fonts for Windows, MacOS X and Linux developed by Mark Simonson and available for free under the Open Font License.  Code looks quite nice in the font when editing.

Another similar font I’ve enjoyed using is “Inconsolata” developed by Raph Levien and also available for free under the Open Font License:

inconsolatafont.jpg

You might ask – why does this matter? I mean, programming code doesn’t have any formatting when it’s compiled, so who cares about the font! Well… if you are working for much of the day using a code editor, it can be great to use a typeface that makes your code very readable on the computer screen or printed output.

What do you think? Are there other fonts that you’ve found you like to use for working with code? (There are many out there…)


Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


Slides available for Voxeo CTO RJ Auburn’s JavaOne talk “Taking a SIP of Java”

Thursday, June 4th, 2009

This week Voxeo CTO RJ Auburn spoke out at the JavaOne conference on the topic of “Taking a SIP of Java“. RJ’s slides are now available on SlideShare at:

http://www.slideshare.net/voxeo/javaone-a-sip-of-java-rj-auburn

And the presentation, also embedded below, looks to be a classic RJ kind of talk… fun, lively, interesting… and also with some code. I don’t know if there were any recordings made, but if there were I’ll update the article with a link. Enjoy the talk!


If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook or following us on Twitter.


Technorati Tags: , , , , ,


Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


IMified Example – An IM bot using Google App Engine

Wednesday, June 3rd, 2009

imifiedlogo.jpgAs you may have noticed last week, we announced the acquisition of a company called IMified and with that we brought in more opportunities and options for developers. Now you can create instant messaging “bots” (or “agents” or whatever you want to call them) that allow you to create applications that interact with users via IM. (More about what you can do with IMified in the acquisition announcement.)

Developer accounts are free over on www.imified.com. Please do sign up and check it out. We’d love to hear what you think of the service. (And you can safely assume that we’ll be evolving the service and adding more to it over the months ahead.)

One aspect of IMified that is a bit different from either Voxeo’s Evolution XML developer portal or our Tropo.com site is that with IMified you do need to host your application on a web server somewhere. With both Evolution and Tropo, you can host your application on your own server and simply point Evolution or Tropo to the URL of your app, but there is also the option with both services of hosting your apps directly within our hosted infrastructure. With IMified you do need to host your application somewhere and then provide the URL inside IMified when configuring your bot.

The beautiful thing about this, of course, is that it means you can write the bot application in whatever language you want on whatever operating system you want and using whatever tools you want. All your application has to do is use the IMified API to communicate with the IMified platform.

One place developers can host a web services app these days is certainly Google App Engine, and the IMified team just posted a knowledge base article showing an example bot in python hosted on Google App Engine. Courtesy of an IMified user named Barry, the source code is available in the IMified knowledge base. The IMified team notes that it’s also a good example of performing HTTP Authentication in python.

(And rather than include the source code here, I’ll just point you over to the IMified site.)

We’re excited about adding IMified to the Voxeo family of services and we’re definitely looking forward to seeing what people develop on the platform.


If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook or following us on Twitter.


Technorati Tags: , , , , , ,


Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


How-To: Outbound Notification Applications

Monday, March 16th, 2009

Outbound notification:

Not only how to do it, but how to do it without blowing things up!

Over here in Voxeo’s Extreme Support, we see a fair amount of tickets asking us how a user might implement their applications on a larger scale, or in what ways our platform could be leveraged to further business needs. ”Hello World” applications might impress your mom, but something has to pay to keep the lights on. One very common use of Voxeo’s technology is outbound notification, where a company sends hundreds, thousands, or even hundreds of thousands of notifications to their customers in an automated fashion. If you have always wanted your very own automated message delivery service, you have come to the right blog. Let’s build a small, but scaleable, one from scratch. The main focus of this posting is to give an overview of how an application like this might be developed. We will show you how several markups and scripting languages can be combined to perform this type of outbound campaign.

Our application will combine PHP and MySQL to launch CCXML/VoiceXML calls using a simple HTTP control mechanism through Voxeo’s hosted network. The control mechanism provides throttling intelligence to our application, ensuring a defined ceiling of concurrent calls will not be surpassed, but still allowing for maximum efficiency and duration. When running call campaigns through a telephony network shared with other customers, everyone wins by adhering to port boundaries.

In the example I am presenting we are using a hypothetical application developed for the ‘XYZ Corporation‘, their needs for their application are as follows:

  • Call users and notify them of appointments
  • Verify that intended callers got the notification
  • If caller chooses to, allow them to change appointments
  • Log results to a database so we can view call history’s and track any problematic sessions reported by users

The requirements are not to overwhelming, however in addition to the above we also want to give them a nice interface to ensure a pleasant user experience. We also want to ensure that this interface will allow for someone without a intimate knowledge of VoiceXML, or even any markup at all to operate our application. After all, our fictitious company ‘XYZ Corp’, is in the business of notifying people about appointments, not debugging application code.

So let me do a quick video run through of the final product before I go into detail on the relevant components below. Below you will see an embedded YouTube video that shows the interface and it’s functions, this might be helpful if you gave this a quick review prior to proceeding, as the rest of the posting is based off this example application and assumes that you have reviewed it:

So first off let me say that all this code is going to be attached for download at the end of this posting. So fear not you will have unfettered access to download, edit, and test any of this to your hearts content. If you wish to deploy this you will need to do so on your own Web Server since the majority is done in PHP. The reason for this is that Voxeo’s shared production network does not allow for server side scripting.

So lets get down and dirty into the components of this application: First off we have our interface which was done in HTML & PHP. The interface is driven by a MySQL database, from which we query for our list of callers and log session results. Now PHP generally falls outside of the scope of our support, so we will not dive to deep into this portion of the application code. It is for the reason we attached the code of the entire application to this posting. The portion I want to focus on here is the throttling mechanism for call launches, the methods we pass data into and out of our CCXML & VoiceXML application for our dialogs. Then finally I will show you how we get the data back from our VoiceXML dialog and log these results back into our database for post call review. At the very end I will have a link to the source code of this entire thing for you to download should you wish to do so. So with out further delay lets take a look at CPS.

Next page…


Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.


The top 100 Blogs and top 50 Twitterers for developers

Wednesday, December 31st, 2008

‘Tis the season for lists, of course, and a colleague recently pointed me to two lists of resources out there for developers:

No, we’re not on either list… but regardless they are good lists of other folks out there writing about software and development. Kudos to Jurgen Appelo for taking the time to put these lists together.

Happy New Year to you all!


If you found this post interesting or helpful, please consider either subscribing via RSS or following on Twitter.



Want to learn how Voxeo can help unlock your communications and deliver a better customer experience? Please contact us!

If you found this post interesting or helpful, please consider either subscribing via RSS, becoming a fan on Facebook, or following us on Twitter.