Set Random Caller ID in VICIdial and GoAutodial

This tutorial explains step by step methods to set random caller IDs on VICidial and GoAutodial. This tutorial is relevant to people using multiple Caller IDs for marketing or re-marketing purposes. Sometimes, the DID provider tends to block a specific DID as it is used to cold call higher number of random numbers due to their fair usage policies. What-so-ever reason it be, here is the tutorial for you to learn.

Please note that your Carrier provider should allow you to use the caller IDs that you will be using as random.

Before you get started, you will need to choose a Random number within a Range (Minimum and Maximum). You can choose a random number, minimum defaults to 0 if not specified, while max may be up to 2147483647. You need to alter the dialplan to get this functionality. Lets get straight into the dialplan.

For eg: Consider the DID Range as 50005001 to 50005999

Option 1: Using Dialplan

Those who use plain Asterisk setup should use the below dialplan.

exten => _9X.,1,Set(Callerid(num)=${RAND(50005001,50005999)})
exten => _9X.,2,Dial(SIP/VOIPTRUNK/${EXTEN:1})
exten => _9X.,3,Hangup()

NOTE: For VICIdial and GoAutodial use the below dialplan.

exten => _9X.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9X.,2,Set(Callerid(num)=${RAND(50005001,50005999)})
exten => _9X.,3,Dial(SIP/VOIPTRUNK/${EXTEN:1},,Tto)
exten => _9X.,4,Hangup()

Option 2: Using PHP AGI Script

This method is useful when you have numbers which are not in range, or numbers are placed in a text file. A random number will be used and set as caller ID while the server dials out.

Note: You must have PHPagi installed in your pbx server under agi directory. This somes preinstalled if you use the ISO of VICIdial or GoAutodial to install your server. Else you can download the PHPagi using this link.

Step 1: Create a file named randomcid.php under /var/lib/asterisk/agi-bin. You can use any ftp application to create the file with ease.

Step 2: Copy the below script and paste in randomcid.php

#!/usr/bin/php
<?php
include ‘phpagi-2.20/phpagi.php’;
$agi = new AGI();
$numbers = file(‘/var/lib/asterisk/agi-bin/cids-list.txt’);
$cid = array_rand($numbers, 1);
//return trim($numbers[$cid[0]]);
$newCID = trim($numbers[$cid]);
//echo $newCID;
$agi->set_variable(“CALLERID(num)”, $newCID);

?>

Step 3: Create a file named cids-list.txt under /var lib/asterisk/agi-bin and fill your numbers in a single column. here is an example.

50005001
50005002
50005003
50005004

Step 4: Time now to write a dialplan with AGI function.

For plain asterisk

exten => _9X.,1,AGI(randomcid.php)
exten => _9X.,2,Dial(SIP/VOIPTRUNK/${EXTEN:1})
exten => _9X.,3,Hangup

For VICIdial/GoAutodial

exten => _9X.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9X.,2,AGI(randomcid.php)
exten => _9X.,3,Dial(SIP/VOIPTRUNK/${EXTEN:1},,tTo)
exten => _9X.,4,Hangup

Step 5: Make the test calls and confirm.

That’s all. Thank you for reading…



Author: Kaushal Kumar
I am a Server-side Linux & Web Technologies professional. I dedicate my full time working towards the overall success of my client's Businesses. I help my clients with their business communications, CRM & ERP, Internet Marketing etc. Want to work together: I'd love to hear from you.

Leave a Reply

This website uses cookies and asks your personal data to enhance your browsing experience. We are committed to protecting your privacy and ensuring your data is handled in compliance with the General Data Protection Regulation (GDPR).