• News
  • Idefisk
  • Tools
  • Tutorials
  • Forum
  • Reviews
  • VoIP Providers
  • Archives
  • Gallery
ZOIPER SIP softphone
Back to Tutorials

6.1.2.64. Read (dialplan application)

1. Read - this application allows you to read a variable.

NOTE: This application is valid for Asterisk version 1.0.9 and above.

 


Syntax:

Read(variable[|filename][|maxdigits][|option][|attempts][|timeout])

 


List with the possible options

variable - the variable, which has to be read

filename - with this parameter you can specify a sound file, which you would like to be played, before the reading. The sound file has to be in the directory /var/lib/asterisk/sounds.

maxdigits - with this argument, you can set the maximum number of digits, which the user could enter. After the maximum is reached, the reading will stop.

option - there are two possible options:
skip - if this one is specified, the application will return immediately, if the line is not up.
noanswer - if this one is specified, then the application will read the digits even if the line is not up

attempts - here you can specify the desired number of attempts, the user has in case of no data is entered.

timeout - with this parameter, you specify the number of second, which the user has, to enter some data. By default the timeout is set to zero.

 


Purpose and usage

The purpose of this application is to read a specified number of digits in a specified variable. The application has many features, including timeout and possibility to play a sound file.

Below, we will give you an example, how to use this application.

 


Prerequisites

To use this application you need a working Asterisk PBX with registered users in iax.conf, sip.conf or mgcp.conf(It depends on which protocol you would like to use) and made extensions.

To see how the application works we recommend to use our IAX softphone Idefisk. You can download it from here. Please also read our tutorial to learn how to configure it to work with Asterisk PBX.

 


Asterisk PBX configurations


NOTE: This is only an example of what for you can use this application. Of course you can use it and for other things.


iax.conf Configurations

We need one registered user in iax.conf file. This is because we are going to use the IAX2 protocol. If you want to use other protocol such as SIP or MGCP, you have to do the configurations below respectively in sip.conf or mgcp.conf.

iaxoneuser.jpg

So, we have registered the user user1

Type=friend means that this user can make and receive calls. Host=dynamic means that the IP is not static but dynamic through a DHCP server. Allow=all means that the line which this user will use, could support all audio codecs. Context=test - this shows that this user is working with the extensions in this context of the configuration file extensions.conf.


extensions.conf Configurations

Now lets take a look at the extensions.conf file.

extread.jpg

On the picture above you can see our extensions.conf file.

When somebody dials 1111, the call will be answered by the Answer application. The next executed extension will be the one which contains the Read application. As arguments in its brackets we have set the following: test|attention-required|4|skip|2|15.

test - the variable which will be read. In other words, this variable will store the digits, which we will enter.

attention-required - the sound file, which we would like the caller to hear. The file will be played before the reading of the digits. The sound file has to be in the directory /var/lib/asterisk/sounds. This is the default directory. You can change it in the asterisk.conf file.

4 - the maximum number of digits the caller could enter.

skip - this means, that the application will return immediately if the line is not up.

2 - this is the maximum number of attempts, the call has, to enter a data.

15 - is the timeout. The caller has 15 seconds to enter a data. If the time expires and there is no data entered and the number of the attempts is greater than 1, then the caller will hear again the sound file and it could try again to enter some digits.

The next executed extension will be the one with the SendText application. Thanks to it, a message will be displayed on the caller’s screen. The message will contain the value of the test variable. In other words it will show us what we have entered with the Read application.

NOTE: Please, pay attention, that when you set the test variable in the Read application, you have to write it without the ${} characters. However, when you call the same variable in the SendText application, you have to write it with the ${} characters

Finally, in order to be sure that the Asterisk PBX will hang up the line after the conversation is over, it is a good idea to make an extension for hanging up the line.

So when somebody dials 1111, the call will be answered by the Answer application. Then, hanks to the Read application, the caller will hear the sound file attention-required, then he/she could enter some digits, but no more than 4. If the caller does not enter anything within 15 seconds, then he/she could try one more time. If the user enters some digits, then a message will appear on its screen. The message will contain the entered digits. The last thing to happen is the closing of the line thanks to the Hangup application.

 


2. Screenshots of what you can see on your Idefisk and on the CLI of the Asterisk PBX

ideread.jpg

cliread.jpg

 


3. Additional information

For more information about extensions.conf you can check here.
For more information about iax.conf you can check here.

This application is tested with our IAX softphone Idefisk. You can download it from here. For more information about this softphone please read our tutorial.

If you would like to test this application with the SIP channel you can read our tutorials about the SIP Softphones to learn how to configure them to work with Asterisk PBX

 


4. Uploaded files

extensions.conf
iax.conf

 


5. Similar dialplan applications

ReadFile()

 

 
User Comments
KG (kgtee at twinson dot com dot sg)
16 June 2006 18:25:58
Can someone write a dialplan to read a SIP URI, in the form of digits punched in from an analog ZAP FXS line, e.g. 200@10.20.30.4 (200#010200300004#?), and later to dial out the SIP URI?

KG (kgtee at twinson dot com dot sg)
16 June 2006 18:25:23
Can someone write a dialplan to read a SIP URI, in the form of digits punched in from an analog ZAP FXS line, e.g. 200@10.20.30.4 (200#010200300004#?), and later to dial out the SIP URI?

Jeroen (jeroen at fluoloine dot net)
12 June 2006 21:38:57
Is it correct that I can't read a pound or hash-key with 'Read'?
pageus (pageus at gmail dot com)
20 April 2006 09:06:40
Wow this makes my life easier.. thanks.. allows me to complete an IVR project i was going nuts over.
Yanuar Kusnadi (yanuar_k2000 at telkom dot net)
27 December 2005 07:56:53
Nice tutorial, very useful ... for beginner like me
 
Add Comment
Name:
Email:
Comment:
In order to prevent automatic posting on our website, we kindly request you to type in the number you see in the picture below.
Image Verification:
 

Latest Headlines:

  • T.38 faxing with Zoiper 2.15 is now easier than ever
    section: voip software
  • Asterisk 1.4.21 Released
    section: Asterisk
  • Asterisk 1.4.20 Released
    section: Asterisk
  • Asterisk 1.4.20-rc2 Released
    section: Asterisk
  • Asterisk 1.4.20-rc1 Now Available
    section: Asterisk
  • News Archives (older news)

Latest Tutorials:

  • VMAuthenticate (dialplan application)
    added 01/Mar/2008 15:57
  • Siptronic ST-530
    added 06/Nov/2007 17:57
  • Siemens C455 IP hardphone
    added 05/Nov/2007 10:24
  • Zoiper
    added 22/Oct/2007 17:53
  • Grandstream GXP-2020
    added 15/Oct/2007 18:17

Latest Comments:

  • It happened that a Dog <a href="http://w...
    section: voip hardware
  • It happened that a Dog <a href="http://w...
    section: voip hardware
  • thinks i installation <A href=\"http:...
    tutorial: Installation on CentOS
  • uh, why not just use the asterisk packag...
    tutorial: Installation on Debian
  • <br /> <p><a href="http://www.7be.com">...
    section: voip software
 
contact us at: support@asteriskguru.com - asterisKGuru.com © all rights reserved   |   *asterisk is registered trademark of © Digium™