New: Record the Whole Conversation

August 06, 2012

We have added a new API to record the whole phone conversation!

Monitor is a new middle block that we have introduced to accomplish this. Once you have used the Monitor API in your call flow, you can continue with using other IVR APIs. When the call finally ends, you will get a notification, which will provide you the MP3 recording in “monitor_url”.

Following is the classic Customer Helpline example which we have extended.

PS: Don’t be confused by Record API, which is used for a one-off recording, like a voicemail.

Tags: , , ,
Posted by:

Go to Voicemail when Transfer Fails

July 10, 2012

We have improved the Transfer API so that you can continue to control the call if the transfer is unsuccessful.

Some of you are using the Transfer API end block to transfer an IVR call to a phone number. However, in the event that the line is busy or the recipient does not answer, there is nothing else you can do.

You have told us that you would like to have control of the call after an unsuccessful transfer, such as sending the call to a voicemail. Now we provide you a way to re-wire the call flow to any middle or  end block! You can use Record API for voicemail, Gather API to ask for another number, or Transfer API to transfer to another number.. It’s up to you!

How to do that?

There is a new request parameter “on_failure” added to Transfer API. You can specify “hangup” (the default) or “continue”. If you choose to continue, you can issue another Middle or End block eg. Play, Gather.

Tags: ,
Posted by:

Hoiio API Example: WeatherByPhone

February 17, 2012

Another simple yet interesting example was developed using Hoiio API.

This example let you check the weather of your location by using your mobile phone. It makes use of Yahoo weather API.

Application flow:

The app requires the WOEID code which is introduced by Yahoo to uniquely identify any location on Earth. To find the WOEID of your location, you can find by browser/search from the Yahoo weather homepage. The WOEID is in the URL for the forecast page for that city. For example, if you search for Singapore on the Weather home page, the forecast page for that city is http://weather.yahoo.com/singapore/central-singapore/singapore-1062617/. The WOEID is 1062617.

The response user will hear is “It is currently 28 degrees celsius and partly cloudy in Singapore“. The application will keep asking the user until he/she hangs up the phone.

Let’s look closer into the code:

  1. Global variables: we define all global variables like appId, accessToken,…
    $appId       = "[Your appId]";
    $accessToken = "[Your accessToken]";
    $server      = "https://secure.hoiio.com/open";
    $myUrl       = "[Your notify URL address]";
    
    1. The appId and accessToken are generated for you when you create an application in the developer portal
    2. The notify URL is the address that Hoiio will notify developer after each step to ask for the next step (or next building block)
  2. The controller: maintain the state of the call to do correct actions
    if ($_POST['call_state'] == "ringing") {
    	askZip();
    	return;
    }
    else if ($_POST['call_state'] == "ongoing") {
    	switch ($_POST['tag']) {
    		case "askZip":
    			checkDigitPressed();
    			break;
    		case "playMessage":
    			askZip();
    			break;
    	}
    }
    else if ($_POST['call_state'] == "ended") {
    	// Call has ended, can do anything here
    }
  3. The askZip() function: send a Gather API to ask for the WOEID codes
    $data = http_build_query(
    	 array(	"app_id" 		=> $GLOBALS['appId'],
    			"access_token" 	=> $GLOBALS['accessToken'],
    			"tag"		=> "askZip",
    			"session"	=> $_POST['session'],
    			"msg"		=> "Please enter your W-O-E-I-D code.",
    			"max_digits"	=> "9",
    			"notify_url" 	=> $GLOBALS['myUrl']));
    
    do_post_request($GLOBALS['server']."/ivr/middle/gather", $data);
    
  4. The checkDigitPressed() function:
    $zip = $_POST['digits'];
    // Checks the zip code
    if (strpos($zip, '*') !== false) {
    	playMessage("You have entered an invalid W-O-E-I-D code");
    }
    else {
    	// Get the forecast
    	$forecastStr = do_get_request("http://weather.yahooapis.com/forecastrss?w=" . $zip . "&u=c");
    
    	if (strpos($forecastStr, "City not found")) {
    		playMessage("You have entered an invalid W-O-E-I-D code");
    	} else {
    		// Extract the temperature info
    		$rss = new SimpleXMLElement($forecastStr);
    		$temp = $rss->channel->item->children('yweather', true)->condition->attributes()->temp;
    		$condition = $rss->channel->item->children('yweather', true)->condition->attributes()->text;
    		$location = $rss->channel->children('yweather', true)->location->attributes()->city;
    
    		playMessage("It is currently ". $temp ." degrees celsius and ". $condition ." in ". $location .".");
    	}
    }
    

    This function verifies the code then send the http request to Yahoo to get the weather information of that location. If the response is “City not found”, it asks again for the WOEID code.

  5. The playMessage() function: play the result to the user
    $data = http_build_query(
    	array(	"app_id" 		=> $GLOBALS['appId'],
    			"access_token" 	=> $GLOBALS['accessToken'],
    			"tag"			=> "playMessage",
    			"session"		=> $_POST['session'],
    			"msg"			=> $msg,
    			"notify_url" 	=> $GLOBALS['myUrl']));
    
    do_post_request($GLOBALS['server']."/ivr/middle/play", $data);
    

That’s it! It’s simple and straight forward and you can do it in less than 30 minutes.

Download

The source code you can download here.

Tags: , ,
Posted by:

Record Voice Messages Over The Phone

December 27, 2011

We have released a new IVR feature – Record API!

With Record API, developers can now use this new middle block in an IVR call flow. After a voice message is recorded, Hoiio will pass the URL of the recording (via the record_url parameter) to your web server via notifications (specified in your notify_url parameter). Refer to the documentation for the details.

If you have wanted to create a voicemail system, now is the time with Hoiio.

Tags: , ,
Posted by:

IVR API Released!

November 01, 2011

Well, to be exact, we have released IVR API for over a month!

We have been quiet about the release, but we are all excited to tell you everything about it now :) 

 

What is IVR?

IVR stands for Interactive Voice Responses. It is most commonly seen in customer hotlines, where you call a number and interact via the phone.

Hoiio’s IVR API is a set of API for creating IVR system that interacts with users through a phone call.

 

What is unique here?

The standard way to create an IVR system is to buy servers, install PBX software such as Asterisk, hook up to VoIP gateways, and lastly, code your dial plans ..

What is unique here is that Hoiio is providing a simple IVR API, and all wrapped in RESTful APIs that web developers are familiar with.

In other words, instead of spending months to learn and develop via the standard way, you can write an IVR app with Hoiio in 10 minutes!

Now, any web developers can create an IVR app!

 

So, what can I create?

With Hoiio’s IVR API, you can create telephony apps such as:

  • Customer Hotline
  • Office Extension
  • Call Screening
  • Phone Polling
  • Voice Broadcast
  • etc..

You can also consider extend your existing apps to support the app over a phone call! For example, it would be nice to find hotels/flights/cafes/buses over a phone call :)

As we speak, some apps are already developed using Hoiio’s IVR API, such as Where-Is-My-Travelling-Parents, Guidebnb and Who-Is-The-Cutest.

To get started, head over to IVR API documentation now!

api-blocks

Tags:
Posted by: