{"id":9832,"date":"2023-03-15T15:23:10","date_gmt":"2023-03-15T20:23:10","guid":{"rendered":"https:\/\/itsoftware.com.co\/content\/?p=9832"},"modified":"2023-03-16T08:48:50","modified_gmt":"2023-03-16T13:48:50","slug":"call-automation-asterisk-issabel-pbx","status":"publish","type":"post","link":"https:\/\/itsoftware.com.co\/content\/call-automation-asterisk-issabel-pbx\/","title":{"rendered":"Call automation with Asterisk and Issabel PBX"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Open source communication systems based on Asterisk, such as Issabel PBX, Elastix or FreePBX, allow call automation, to interact with users, and additionally receive or send information from other platforms.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/asterisk-logo-1.png\" alt=\"Call automation with Asterisk\" class=\"wp-image-8813\" width=\"474\" height=\"180\" srcset=\"https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/asterisk-logo-1.png 600w, https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/asterisk-logo-1-300x114.png 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><figcaption class=\"wp-element-caption\">Call automation with Asterisk<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><br>Now we will detail about Asterisk&#8217;s options for call automation:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">1. <strong>Asterisk&#8217;s Dialplan<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The dialplan is a script specific to Asterisk, which controls the sequence of a call, and therefore the different decisions that can be made, according to the responses of the user, or another system integrated to it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Depending on the Asterisk distribution, some are automatically created or modified by Issabel (extensions.conf and extensions_additional.conf), and there is another one that can be modified manually by the user (extensions_custom.conf).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In general, a dialplan is headed by a context, which is named between the symbols []. Below the context there are the different lines of the dialplan, conformed as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong><em>[context]<\/em><\/strong>\n<em style=\"\"><b>exten =&gt; extension, priority, Command(<\/b><\/em><strong><em>parameters)<\/em><\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Where the <strong>extension <\/strong>indicates the number that a user dials, or a number that enters through a trunk; the <strong>priority <\/strong>shows the sequence of execution of the commands, and the <strong>Command <\/strong>is the application that you want to execute.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example the line:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">exten =&gt; 123,1,SayDigits(485)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Instructs asterisk so that when the user dials 123 or the number 123 is received on the trunk, it first executes the action: read the digits 485.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. <strong>AGI &#8211; Asterisk Gateway Interface<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">AGI is a function that allows the execution of PHP, Perl or Phyton scripts external to Asterisk, exchanging information between Asterisk and other systems or databases. The AGI application allows parameters to be sent to the script to be its input data. The script returns data to Asterisk by means of variables that are loaded through an AGI object.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The script file must be located in the \/var\/lib\/asterisk\/asterisk\/agi-bin directory, with execution permissions. This file must contain a structure as shown:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">!\/usr\/bin\/php -q\n\n&lt;?php \n\nrequire(\"\/var\/lib\/asterisk\/agi-bin\/phpagi.php\");\n\n\/\/Get parameters from asterisk\n\n$p1 = $arg[1];\n\n\/\/ Execute code from PHP \n\n...\n\n\/\/ Return values to asterisk \n\n$agi = new AGI();\n$agi-&gt;answer();\n$agi-&gt;set_variable('exit',$exit);\n\n?&gt;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The variables returned to asterisk through the agi object are accessible through the ${var} format.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, if we have a php script called action.php, it can be called from the dialplan as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">exten =&gt; 123,1,ExecIf($[\"${follow}\"=\"1\" ]?AGI(action.php,${p1},{p2}))<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, the script <em>action.php<\/em> is executed with the parameters <em>p1 <\/em>and <em>p2<\/em>, when the continuous variable has a value equal to 1.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, the AGI object can also perform the whole dialplan sequence from the script itself, by means of commands that execute from the script to the asterisk, for example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ Get caller ID\n$cid = $agi-&gt;parse_callerid();\n\n\/\/ Sounds text to audio\n$agi-&gt;text2wav(\"Hi, good morning\");\n\n\/\/ Hang up the call\n$agi-&gt; hangup();<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this way, the entire logical sequence of the call is controlled from the script, with the facilities and functions that the supported programming languages contain.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. Access to MySQL from the dialplan<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">From the dialplan it is possible to connect to a local or external database, through the MySQL application, integrating the results of the queries to dialplan variables, or executing other actions in the database such as inserting, updating or deleting data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The use of this function is performed as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">; Connection to database, with a valid username and password \nexten =&gt; _X.,n,MYSQL(Connect connid ${serverdb} ${userdb} ${passdb} ${dbname})\n\n; Execute query MySQL\nexten =&gt; _X.,n,MYSQL(Query r1 ${connid} SELECT p1, p2 FROM tabla where p2='${EXTEN}')\n\n; The results of the query are assigned to Asterisk variables.\nexten =&gt; _X.,n,MYSQL(Fetch fetchid ${r1} p1 p2)\n\n; The query is free\nexten =&gt; _X.,n,MYSQL(Clear ${r1})\n\n; Disconnect database\nexten =&gt; _X.,n,MYSQL(Disconnect ${connid})<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4. AMI &#8211; Asterisk Manager Interface<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is a way to integrate Asterisk with external applications, through a TCP\/IP type interface, based on key : value queries.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this way you can send commands to Asterisk, receive their response and also receive events when they occur.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">AMI is enabled in Asterisk in the <em>manager.conf<\/em> file. In this file are the login credentials and the IP addresses with permission or denial to execute commands.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, once the TCP connection to Asterisk is established, commands can be sent such as:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Action: Login\nActionID: 1\nUsername: administrator\nSecret: password1\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Receiving a reply from Asterisk as:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Response: Success\nActionID: 1\nMessage: Authentication accepted\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<!--nextpage-->\n\n\n\n<h2 class=\"wp-block-heading\">5. <strong>Automatic calls<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Asterisk allows the execution of calls automatically, by means of .call extension files, which are located in a specific directory of the Asterisk server, in the case of Centos, the directory is <em>\/var\/spool\/asterisk\/outgoing<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the .<em>call <\/em>file you can include options such as the number of times a call will be attempted, what will be its outgoing trunk, what will be the context, extension and priority in the dialplan it will use, and you can also set variables that may be required by the asterisk in the execution of the call sequence.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is an example of a file called call.call to communicate to a mobile number 3168459103, using the trunk TRK1, setting a variable ${var1} for Asterisk, trying 3 times, waiting 2 hours between calls:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Channel: SIP\/TRK1\/3168459103\nMaxRetries: 3\nWaitTime: 7200\nContext: out-pbx\nExtension: s\nPriority: 1\nSet: var1=5<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">6. <strong>Festival Text to Speech<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Festival is an application that allows you to convert text to speech, from the dialplan or an external script.<br>If you wish to use more powerful text to audio conversion platforms, you can do the process by communicating via the service provider&#8217;s API.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">7. <strong>Issabel&#8217;s customized modules<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Issabel PBX allows the creation of custom modules through the Addon Developer, with which you create the necessary menus to call functions, which can report operations or make configuration changes in a database.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"600\" height=\"229\" src=\"https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/issabel-1.png\" alt=\"Issabel PBX\" class=\"wp-image-8816\" srcset=\"https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/issabel-1.png 600w, https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/issabel-1-300x115.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><figcaption class=\"wp-element-caption\">Issabel PBX<\/figcaption><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"600\" height=\"87\" src=\"https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/issabel-developer-addon-1.png\" alt=\"Issabel Developer Addon\" class=\"wp-image-8817\" srcset=\"https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/issabel-developer-addon-1.png 600w, https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/issabel-developer-addon-1-300x44.png 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><figcaption class=\"wp-element-caption\">Issabel Developer Addon<\/figcaption><\/figure>\n<\/div>\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><br>What can you do with these Asterisk call automation alternatives?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The flexibility of the dialplan and the execution of scripts through the AGI or the AMI, allow calls to be made, with customer interaction through an IVR, receiving and sending information with other systems and their databases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this way it is possible to automate calls, either to attend requests in a help desk, or to consult flight status, hotel reservations, shipment status, failure alerts, and any type of interaction required between a customer and a system external to asterisk, with which you want to expose or save your input data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If your company needs to automate some of its processes through Asterisk and its different options, do not forget to contact us to our Whatsapp, there we can advise and help you with your needs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This article is part of <strong><a href=\"https:\/\/itsoftware.com.co\/content\/software-development-company\/\" target=\"_blank\" rel=\"noopener\" title=\"ITSoftware \u2013 Software &amp; Mobile Apps Develpment | Data Analytics\">ITSoftware <\/a><\/strong>knowledge program system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you liked it, please don&#8217;t forget to share it on social networks. \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Open source communication systems based on Asterisk, such as Issabel PBX, Elastix or FreePBX, allow call automation, to interact with users, and additionally receive or send information from other platforms.[&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":8816,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1384,305,1244],"tags":[384,1558,1559,1560],"class_list":["post-9832","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asterisk","category-automatizacion","category-telecomunicaciones","tag-asterisk","tag-elastix","tag-freebpx","tag-issabel"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/itsoftware.com.co\/content\/wp-content\/uploads\/2021\/08\/issabel-1.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/posts\/9832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/comments?post=9832"}],"version-history":[{"count":0,"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/posts\/9832\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/media\/8816"}],"wp:attachment":[{"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/media?parent=9832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/categories?post=9832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itsoftware.com.co\/content\/wp-json\/wp\/v2\/tags?post=9832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}