TeleStax.orgCommunity Documentation
In this chapter, you will learn how to use more advanced features of Restcomm verbs to create communications applications
You must get an API key from http://www.voicerss.org in order to proceed with this section. You can register for a free account and an API key will be emailed to you. Once you have the API key, open the $RESTCOMM_HOME/standalone/deployments/restcomm.war/WEB-INF/conf/restcomm.xml file and find the speech-synthesizer VoiceRSS section. Add your API key as shown below and restart RestComm
<speech-synthesizer class="org.mobicents.servlet.restcomm.tts.VoiceRSSSpeechSynthesizer"> <service-root>http://api.voicerss.org</service-root> <apikey>2901c0aXXXXXXXXXXXXXX</apikey>
Once you have done that, you are ready to use Text-to-Speech feature of RestComm.
Create a file called test.xml in the $RESTCOMM_HOME/standalone/deployments/restcomm.war/demos/ directory and copy the content of the application below into the test.xml file and save it
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Welcome to RestComm, you have successfully tested the Say Verb</Say>
</Response>
From a command terminal run the Curl command below to bind the 5555 phone number to the test.xml file.
curl -X POST http://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/IncomingPhoneNumbers.json -d "PhoneNumber=5555" -d "VoiceUrl=http://127.0.0.1:8080/restcomm/demos/test.xml"
If the command is successful, you will see an output similar to the following:
{
"sid": "PN0834628c131e4b66bc862ae0b21b7cfa",
"account_sid": "ACae6e420f425248d6a26948c17a9e2acf",
"friendly_name": "5555",
"phone_number": "+15555",
"voice_url": "http://127.0.0.1:8080/restcomm/demos/hello-play.xml",
"voice_method": "POST",
"voice_fallback_method": "POST",
"status_callback_method": "POST",
"voice_caller_id_lookup": false,
"date_created": "2013-08-15T17:45:21.409-06:00",
"date_updated": "2013-08-15T17:45:21.409-06:00",
"sms_method": "POST",
"sms_fallback_method": "POST",
"api_version": "2012-04-24",
"uri": "/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/IncomingPhoneNumbers/PN0834628c131e4b66bc862ae0b21b7cfa.json"
Next, you have to configure your SIP phone and make a call to the test.xml dialing number 5555
Some SIP phones have been known to have codec problems and do not correctly render the application as desired. In this example, we shall be using Ekiga.
Start the SIP phone Ekiga (see below) and dial 5555@127.0.0.1:5080. You will hear the content of the Say Verb in the test.xml file.

Create a file called test.xml in the $RESTCOMM_HOME/standalone/deployments/restcomm.war/demos/ directory and copy the content of the application below into the test.xml file and save it. Dial the number 5555 and when you hear the beep sound, leave a message and hangup when you are finished.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Welcome to RestComm, leave a message after the beep</Say>
<Record maxLength="30"/>
</Response>
A wave file will be recorded and saved in the $RESTCOMM_HOME/standalone/deployments/restcomm.war/recordings/ directory. You can use any media player to listen to the recorded voice message.
In order to use the Dial verb, you will need two users and register them to RestComm.
Restcomm has already two users created for you for testing purposes, alice and bob
Alice Restcomm client. Username = alice / Password = 1234
Bob Restcomm client. Username = bob / Password = 1234
Register Alice and Bob using softphone Sflphone.
In order to start two instances of Sflphone on the same computer, you need to start the second instance using sudo Sflphone.
When Sflphone is started, go to the the menu Edit->Accounts, then press the Add button
Fill out the configuration for Bob as shown in the screenshot below:
Sflphone Basic Configuration.

Sflphone Advanced Configuration. Make sure the port number is set to 5061

In the second instance of Sflphone, register user Alice following the same procedure used for Bob. In the Advanced settings, make sure the port number for user Alice is set to 5060
Copy the content of the application below into the test.xml file and save. .
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Welcome to RestComm, you are being forwarded to Alice</Say>
<Dial callerid="+123456789">
<Client>alice</Client>
</Dial>
</Response>
From the Sflphone registered with user Bob, make a call to Alice. Enter the name alice and make the call
Copy the Dial Uri application below to the test.xml. Remember that the port number for user Alice is 5060 and that is the port that is used in the application. If you want to use a different port, you also have to change the SIP Uri to reflect that. You can then make a call from user Bob to Alice.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Welcome to RestCom, you are being forward to Alice</Say>
<Dial callerid="+1234567899">
<Uri>sip:alice@127.0.0.1:5060</Uri>
</Dial>
</Response>
Copy the Dial Conference application below to the test.xml and save the file. You can dial any number like 4321 and RestComm will read the Say verb and make a beep sound when you join the conference room. You can use another SIP phone to join the same conference. It works better if you are on a different computer as this reduces the echo generated from the microphones.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Welcome to RestCom, you are now joining the conference room</Say>
<Dial>
<Conference>test-conference</Conference>
</Dial>
</Response>
This verb is used to get user input and instruct RestComm to perform a specific task. This example is a little bit more elaborate and it will require the creation of a php file. You also must host the php file on a web server like Apache. Copy the Gather application below into the test.xml and save the file.
<?xml version="1.0" encoding="UTF-8"?> <Response> <Gather action="http://127.0.0.1/test-user-input.php" numDigits="1"> <Say>Welcome to Telestax RestCom.</Say> <Say>For opening hours, press 1.</Say> <Say>to talk to Alice, press 2.</Say> </Gather> <!-- If customer doesn't input anything, prompt and try again. --> <Say>Sorry, I didn't get your response.</Say> <Redirect>http://127.0.0.1:8080/restcomm/demos/test.xml</Redirect> </Response>
Create a php file in the Apache /var/www/html directory.
You can use any web server of your choice, in this example, we shall be using Apache on a Linux computer
Start the httpd server as follows sudo service httpd start
Create a new file called test-user-input.php in the /var/www/html directory
Copy the php application below into the test-user-input.php and save
<?php
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<Response>';
$user_input = (int) ($_POST['Digits']);
if ($user_input == 1)
{
echo '<Say>Our Opening hours are 24 hours 7 Days a week </Say>';
echo '<Say>Telestax appreciates your business</Say>';
echo '<Say>You may Hang up or wait to be redirected to the main menu</Say>';
echo '<Redirect>http://127.0.0.1:8080/restcomm/demos/test.xml</Redirect>';
} elseif($user_input == 2) {
echo '<Say>You are being forwarded to Alice</Say>';
echo '<Dial callerid="+1234568789">';
echo '<Client>alice</Client>';
echo '</Dial>';
}
echo '</Response>';
?>
This example welcomes the user and offers two options. If the user presses 1, he hears the openining hours message. If the user presses 2, he will be redirected to user Alice.
To test the application using the Gather verb, dial any number from user Bob and follow the application instruction.
Please note that Telestax also offers TelScale RestComm hosted on Amazon AWS. If you want to learn more about how to use DID provisioning and more, please visit www.telestax.com