How to set random callerid in vicidial and asterisk

Vicidial Random Callerid

Topic: 
How to set random callerid in vicidial 
Asterisk dialplan to set random callerid
Asterisk AGI script to set random callerid


vicidial random callerid


  Overview : Why Random Caller ID ?

    There are many reasons to set a Random callerid or auto rotate the callerid, the First Reason is The TrueCaller App in which a customer can mark a Callerid as SPAM which reflect to others who using the Same App which will pop up as spam before atteding the call,
 Next Reason in Callcenters they need to Call leads multiple times throughout the day without using the same number every time
 Next Reason some times the telco blocks the calls received from same callerid over a short period of time.


  Vicidial Random Callerid Options:

    Vicidial is an enterprise class, open source, contact center suite in use by many large call centers around the world. VICIdial has a full featured predictive dialer.  It is capable of inbound, outbound, and blended phone call handling. 


    In Vicidial the Random callerid can be achived using the follwing options
1. Vicidial CID Group settings 
2. Asterisk Dialplan with Rand Function
3. Asterisk AGI script and text file with list of numbers

  Option 1: Vicidial CID Groups

    Vicidial latest version support the option called CID group, which is similar to the Campaign AC-CID, but you can use same CID group  across multiple Campaigns.
With CID Group you can set CID state wise , Area code wise if both these option is not selected then all the CID's will be rotated with every calls ,like random callerid .

Steps to enable CID Group

Navigate to ADMIN > SYSTEM SETTINGS , make sure below option is enabled by setting the value to 1
Enable CID Groups and Campaign Areacode CID :1

once enabled Navigate to  ADMIN > CID GROUPS

add a CID Group and fill the below values
CID Group ID: 10001
CID Group Note: Random callerid
CID Group Type: NONE
Admin User Group: All Admin User Groups
Submit

in the Next section add your CID one by one with Description and press ADD button
Followed to that click CHECKBOX under ACTIVE column to activate this CID 
either select select all to activate all CID's and press SUBMIT CHANGES

Next Go to your campaign detail view and enable this new CID Group from the dropdown.
CID GROUP: 10001
once select press SUBMIT 

  Option 2 : Asterisk RAND function 

       RAND Function can be used in a scenario , if you have a range of DID's  like  40004001 to 40004999
pick any one number randomly within this range and set it has callerid.
Before entering the dialplan , let me explain little bit about RAND function

Asterisk Function RAND

Synopsis:
Choose a random number within a range

Description:
RAND(min,max)
choose a random number between min and max , min default to 0 if not specified,  while max may be upto 2147483647

Lets get in to dialplan
For eg:  consider the DID range as 40004001 to 40004999
those who use plain asterisk setup use the below dialplan
exten => _9X.,1,Set(CALLERID(num)=${RAND(40004001,40004999)})
exten => _9X.,2,Dial(SIP/VOIPTRUNK/${EXTEN:1})
exten => _9X.,3,Hangup()

Note:
for vicidail /goautodial you have to use below dialplan
exten => _9X.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9X.,2,Set(CALLERID(num)=${RAND(40004001,40004999)})
exten => _9X.,3,Dial(SIP/VOIPTRUNK/${EXTEN:1},,Tto)
exten => _9X.,4,Hangup()

  Option 3 :  Using asterisk AGI script 

            This method can be used were you have  numbers ie: not in range,  numbers are placed in a txt file, from which a  random number will be filtered and set as callerid.

note: you must have PHPAgi  installed in your pbx server under agi directory
phpagi download link

https://sourceforge.net/projects/phpagi/files/

a.  Download the PhpAgi from above link to your windows desktop
b.  Use winscp Copy the file to /var/lib/asterisk/agi-bin  directory.
c.  use putty to login to linux /asterisk server
d . cd /var/lib/asterisk/agi-bin/

e.  tar -xvzf phpagi-2.20.tgz
f.   chmod -R 777 phpagi-2.20
g. create a file named randomcid.php  under  /var/lib/asterisk/agi-bin

 cd /var/lib/asterisk/agi-bin
 vi randomcid.php

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);

?>

3. create a file named cids-list.txt    under /var/lib/asteisk/agi-bin
    and fill you numbers in a single column 
    vi /var/lib/asterisk/agi-bin/cids-list.txt

4. now we will 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 or 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


Next Post Previous Post
3 Comments
  • gopi baskar
    gopi baskar April 4, 2022 at 11:39 AM

    How to set Random Callerid in asterisk(vicidial goautodial freepbx)

  • Anonymous
    Anonymous August 4, 2022 at 8:53 PM

    I have cluster setup so where this needs to be done? In every Asterisk server or Web Server?

    • gopi baskar
      gopi baskar August 4, 2022 at 10:34 PM

      yes every asterisk server which used to dialout via carrier

Add Comment
comment url