Freepbx caller id random

NethServer Version: 7.9
Module: freepbx

Good afternoon friends, I come to you because I need freepbx to be able to send different CALLER IDs from a list of the 20 DIDs that I acquired with my SIP operator, I must send those numbers to my provider.
I don’t know how I can continue, I was looking at a script that could work but I don’t know how to implement it.

Option 2 : Using php 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 clickhere

1a. Download the PhpAgi from this link to your windows desktop
1b. Use winscp Copy the file to /var/lib/asterisk/agi-bin directory.
1c. use putty to login to linux /asterisk server
1d . cd /var/lib/asterisk/agi-bin/
1e. tar -xvzf phpagi-2.20.tgz
1f. chmod -R 777 phpagi-2.20

1G. 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)
same => n,Dial(SIP/VOIPTRUNK/${EXTEN:1})
same => n,Hangup

I appreciate the help you can give me

Hi Julian,
AGI method seems correct overall, the only information I think is missing is where to write the dialplan.
If you whant to change number for all the calls, write in
/etc/asterisk/extensions_override_freepbx.conf
and this should be good

[macro-dialout-trunk-predial-hook]
exten => s,1,AGI(randomcid.php)

otherwise, write the dialplan as suggested in /etc/asterisk/extensions_custom.conf and use the 9 before the number you dial

I’d avoid download of phpagi 2, isn’t necessaryand I’d just:
create the agi

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

paste

#!/usr/bin/env php
<?php
     include 'phpagi.php';
     $agi = new AGI();
     $numbers = file('/var/lib/asterisk/agi-bin/cids-list.txt');
     $cid = array_rand($numbers, 1);
     $newCID = trim($numbers[$cid]);
     $agi->set_variable("CALLERID(num)", $newCID);

then

vi /etc/asterisk/extensions_override_freepbx.conf

and paste

[macro-dialout-trunk-predial-hook]
exten => s,1,AGI(randomcid.php)

fix files permissions with

scl enable rh-php56 -- fwconsole chown

apply changes

scl enable rh-php56 -- fwconsole r

and make a call looking at the asterisk console

asterisk -rvvvvv

in asterisk console you could also have debug on agi with the command agi set debug on

2 Likes

Stefano, thank you very much for your help.
I’ll tell you that I did everything to the letter but my caller ids still don’t come out.

I don’t know what I could be missing…

Connected to Asterisk 13.38.3 currently running on nethserver (pid = 2981)
  == Setting global variable 'SIPDOMAIN' to '10.0.15.2'
  == Using SIP RTP Audio TOS bits 184
  == Using SIP RTP Audio TOS bits 184 in TCLASS field.
  == Using SIP RTP Audio CoS mark 5
  == Using SIP RTP Video TOS bits 136
  == Using SIP RTP Video TOS bits 136 in TCLASS field.
  == Using SIP RTP Video CoS mark 4
[2022-01-19 22:12:52] NOTICE[15108]: res_pjsip_sdp_rtp.c:423 set_caps: No joint capabilities for 'video' media stream between our configuration((h264|mpeg4)) and incoming SDP((h263))
    -- Executing [3135566449@from-internal:1] Macro("PJSIP/212-00000004", "user-callerid,LIMIT,EXTERNAL,") in new stack
    -- Executing [s@macro-user-callerid:1] Set("PJSIP/212-00000004", "TOUCH_MONITOR=1642648372.4") in new stack
    -- Executing [s@macro-user-callerid:2] Set("PJSIP/212-00000004", "AMPUSER=212") in new stack
    -- Executing [s@macro-user-callerid:3] Set("PJSIP/212-00000004", "HOTDESCKCHAN=212-00000004") in new stack
    -- Executing [s@macro-user-callerid:4] Set("PJSIP/212-00000004", "HOTDESKEXTEN=212") in new stack
    -- Executing [s@macro-user-callerid:5] Set("PJSIP/212-00000004", "HOTDESKCALL=0") in new stack
    -- Executing [s@macro-user-callerid:6] ExecIf("PJSIP/212-00000004", "0?Set(HOTDESKCALL=1)") in new stack
    -- Executing [s@macro-user-callerid:7] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(name)=)") in new stack
    -- Executing [s@macro-user-callerid:8] GotoIf("PJSIP/212-00000004", "0?report") in new stack
    -- Executing [s@macro-user-callerid:9] ExecIf("PJSIP/212-00000004", "1?Set(REALCALLERIDNUM=212)") in new stack
    -- Executing [s@macro-user-callerid:10] Set("PJSIP/212-00000004", "AMPUSER=212") in new stack
    -- Executing [s@macro-user-callerid:11] GotoIf("PJSIP/212-00000004", "0?limit") in new stack
    -- Executing [s@macro-user-callerid:12] Set("PJSIP/212-00000004", "AMPUSERCIDNAME=Julian Felipe Hoyos Montoya") in new stack
    -- Executing [s@macro-user-callerid:13] ExecIf("PJSIP/212-00000004", "0?Set(__CIDMASQUERADING=TRUE)") in new stack
    -- Executing [s@macro-user-callerid:14] GotoIf("PJSIP/212-00000004", "0?report") in new stack
    -- Executing [s@macro-user-callerid:15] Set("PJSIP/212-00000004", "AMPUSERCID=212") in new stack
    -- Executing [s@macro-user-callerid:16] Set("PJSIP/212-00000004", "__DIAL_OPTIONS=HhTtr") in new stack
    -- Executing [s@macro-user-callerid:17] Set("PJSIP/212-00000004", "CALLERID(all)="Julian Felipe Hoyos Montoya" <212>") in new stack
    -- Executing [s@macro-user-callerid:18] Set("PJSIP/212-00000004", "HOTDESCKCHAN=212-00000004") in new stack
    -- Executing [s@macro-user-callerid:19] Set("PJSIP/212-00000004", "HOTDESKEXTEN=212") in new stack
    -- Executing [s@macro-user-callerid:20] Set("PJSIP/212-00000004", "HOTDESKCALL=0") in new stack
    -- Executing [s@macro-user-callerid:21] ExecIf("PJSIP/212-00000004", "0?Set(HOTDESKCALL=1)") in new stack
    -- Executing [s@macro-user-callerid:22] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(name)=)") in new stack
    -- Executing [s@macro-user-callerid:23] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(all)="" <  >)") in new stack
    -- Executing [s@macro-user-callerid:24] ExecIf("PJSIP/212-00000004", "0?Set(CUSDIAL=)") in new stack
    -- Executing [s@macro-user-callerid:25] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(all)="Julian Felipe Hoyos Montoya" <212>)") in new stack
    -- Executing [s@macro-user-callerid:26] GotoIf("PJSIP/212-00000004", "0?limit") in new stack
    -- Executing [s@macro-user-callerid:27] ExecIf("PJSIP/212-00000004", "1?Set(GROUP(concurrency_limit)=212)") in new stack
    -- Executing [s@macro-user-callerid:28] NoOp("PJSIP/212-00000004", "Macro Depth is 1") in new stack
    -- Executing [s@macro-user-callerid:29] GotoIf("PJSIP/212-00000004", "1?report2:macroerror") in new stack
    -- Goto (macro-user-callerid,s,30)
    -- Executing [s@macro-user-callerid:30] GotoIf("PJSIP/212-00000004", "1?continue") in new stack
    -- Goto (macro-user-callerid,s,48)
    -- Executing [s@macro-user-callerid:48] Set("PJSIP/212-00000004", "CALLERID(number)=212") in new stack
    -- Executing [s@macro-user-callerid:49] Set("PJSIP/212-00000004", "CALLERID(name)=Julian Felipe Hoyos Montoya") in new stack
    -- Executing [s@macro-user-callerid:50] GotoIf("PJSIP/212-00000004", "0?cnum") in new stack
    -- Executing [s@macro-user-callerid:51] Set("PJSIP/212-00000004", "CDR(cnam)=Julian Felipe Hoyos Montoya") in new stack
    -- Executing [s@macro-user-callerid:52] Set("PJSIP/212-00000004", "CDR(cnum)=212") in new stack
    -- Executing [s@macro-user-callerid:53] Set("PJSIP/212-00000004", "CHANNEL(language)=es") in new stack
    -- Executing [3135566449@from-internal:2] Gosub("PJSIP/212-00000004", "sub-record-check,s,1(out,3135566449,yes)") in new stack
    -- Executing [s@sub-record-check:1] GotoIf("PJSIP/212-00000004", "0?initialized") in new stack
    -- Executing [s@sub-record-check:2] Set("PJSIP/212-00000004", "__REC_STATUS=INITIALIZED") in new stack
    -- Executing [s@sub-record-check:3] Set("PJSIP/212-00000004", "NOW=1642648372") in new stack
    -- Executing [s@sub-record-check:4] Set("PJSIP/212-00000004", "__DAY=19") in new stack
    -- Executing [s@sub-record-check:5] Set("PJSIP/212-00000004", "__MONTH=01") in new stack
    -- Executing [s@sub-record-check:6] Set("PJSIP/212-00000004", "__YEAR=2022") in new stack
    -- Executing [s@sub-record-check:7] Set("PJSIP/212-00000004", "__TIMESTR=20220119-221252") in new stack
    -- Executing [s@sub-record-check:8] Set("PJSIP/212-00000004", "__FROMEXTEN=212") in new stack
    -- Executing [s@sub-record-check:9] Set("PJSIP/212-00000004", "__MON_FMT=wav") in new stack
    -- Executing [s@sub-record-check:10] NoOp("PJSIP/212-00000004", "Recordings initialized") in new stack
    -- Executing [s@sub-record-check:11] ExecIf("PJSIP/212-00000004", "0?Set(ARG3=dontcare)") in new stack
    -- Executing [s@sub-record-check:12] Set("PJSIP/212-00000004", "REC_POLICY_MODE_SAVE=") in new stack
    -- Executing [s@sub-record-check:13] ExecIf("PJSIP/212-00000004", "0?Set(REC_STATUS=NO)") in new stack
    -- Executing [s@sub-record-check:14] GotoIf("PJSIP/212-00000004", "3?checkaction") in new stack
    -- Goto (sub-record-check,s,17)
    -- Executing [s@sub-record-check:17] GotoIf("PJSIP/212-00000004", "1?sub-record-check,out,1") in new stack
    -- Goto (sub-record-check,out,1)
    -- Executing [out@sub-record-check:1] NoOp("PJSIP/212-00000004", "Outbound Recording Check from 212 to 3135566449") in new stack
    -- Executing [out@sub-record-check:2] Set("PJSIP/212-00000004", "RECMODE=dontcare") in new stack
    -- Executing [out@sub-record-check:3] ExecIf("PJSIP/212-00000004", "1?Goto(routewins)") in new stack
    -- Goto (sub-record-check,out,7)
    -- Executing [out@sub-record-check:7] Gosub("PJSIP/212-00000004", "recordcheck,1(yes,out,3135566449)") in new stack
    -- Executing [recordcheck@sub-record-check:1] NoOp("PJSIP/212-00000004", "Starting recording check against yes") in new stack
    -- Executing [recordcheck@sub-record-check:2] Goto("PJSIP/212-00000004", "yes") in new stack
    -- Goto (sub-record-check,recordcheck,9)
    -- Executing [recordcheck@sub-record-check:9] ExecIf("PJSIP/212-00000004", "0?Return()") in new stack
    -- Executing [recordcheck@sub-record-check:10] Set("PJSIP/212-00000004", "__REC_POLICY_MODE=YES") in new stack
    -- Executing [recordcheck@sub-record-check:11] Goto("PJSIP/212-00000004", "startrec") in new stack
    -- Goto (sub-record-check,recordcheck,16)
    -- Executing [recordcheck@sub-record-check:16] NoOp("PJSIP/212-00000004", "Starting recording: out, 3135566449") in new stack
    -- Executing [recordcheck@sub-record-check:17] Set("PJSIP/212-00000004", "__CALLFILENAME=out-3135566449-212-20220119-221252-1642648372.4") in new stack
    -- Executing [recordcheck@sub-record-check:18] MixMonitor("PJSIP/212-00000004", "2022/01/19/out-3135566449-212-20220119-221252-1642648372.4.wav,abi(LOCAL_MIXMON_ID),") in new stack
    -- Executing [recordcheck@sub-record-check:19] Set("PJSIP/212-00000004", "__MIXMON_ID=0x7f1dec051f30") in new stack
    -- Executing [recordcheck@sub-record-check:20] Set("PJSIP/212-00000004", "__RECORD_ID=PJSIP/212-00000004") in new stack
    -- Executing [recordcheck@sub-record-check:21] Set("PJSIP/212-00000004", "__REC_STATUS=RECORDING") in new stack
    -- Executing [recordcheck@sub-record-check:22] Set("PJSIP/212-00000004", "CDR(recordingfile)=out-3135566449-212-20220119-221252-1642648372.4.wav") in new stack
    -- Executing [recordcheck@sub-record-check:23] Return("PJSIP/212-00000004", "") in new stack
    -- Executing [out@sub-record-check:8] Return("PJSIP/212-00000004", "") in new stack
    -- Executing [3135566449@from-internal:3] Set("PJSIP/212-00000004", "_ROUTEID=1") in new stack
    -- Executing [3135566449@from-internal:4] Set("PJSIP/212-00000004", "_ROUTENAME=outboundroutes-colombia-mobil") in new stack
    -- Executing [3135566449@from-internal:5] Set("PJSIP/212-00000004", "MOHCLASS=default") in new stack
    -- Executing [3135566449@from-internal:6] Set("PJSIP/212-00000004", "_CALLERIDNAMEINTERNAL=Julian Felipe Hoyos Montoya") in new stack
    -- Executing [3135566449@from-internal:7] Set("PJSIP/212-00000004", "_CALLERIDNUMINTERNAL=212") in new stack
    -- Executing [3135566449@from-internal:8] Set("PJSIP/212-00000004", "_EMAILNOTIFICATION=FALSE") in new stack
    -- Executing [3135566449@from-internal:9] Set("PJSIP/212-00000004", "_NODEST=") in new stack
    -- Executing [3135566449@from-internal:10] Macro("PJSIP/212-00000004", "dialout-trunk,3,573135566449,,off") in new stack
    -- Executing [s@macro-dialout-trunk:1] Set("PJSIP/212-00000004", "DIAL_TRUNK=3") in new stack
    -- Executing [s@macro-dialout-trunk:2] ExecIf("PJSIP/212-00000004", "0?Set(DIAL_OPTIONS=Hhtr)") in new stack
    -- Executing [s@macro-dialout-trunk:3] GosubIf("PJSIP/212-00000004", "0?sub-pincheck,s,1()") in new stack
    -- Executing [s@macro-dialout-trunk:4] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(num)=212)") in new stack
    -- Executing [s@macro-dialout-trunk:5] GotoIf("PJSIP/212-00000004", "0?disabletrunk,1") in new stack
    -- Executing [s@macro-dialout-trunk:6] Set("PJSIP/212-00000004", "DIAL_NUMBER=573135566449") in new stack
    -- Executing [s@macro-dialout-trunk:7] Set("PJSIP/212-00000004", "DIAL_TRUNK_OPTIONS=HhTtr") in new stack
    -- Executing [s@macro-dialout-trunk:8] Set("PJSIP/212-00000004", "OUTBOUND_GROUP=OUT_3") in new stack
    -- Executing [s@macro-dialout-trunk:9] Set("PJSIP/212-00000004", "DIAL_TRUNK_OPTIONS=T") in new stack
    -- Executing [s@macro-dialout-trunk:10] GotoIf("PJSIP/212-00000004", "1?nomax") in new stack
    -- Goto (macro-dialout-trunk,s,12)
    -- Executing [s@macro-dialout-trunk:12] GotoIf("PJSIP/212-00000004", "0?skipoutcid") in new stack
    -- Executing [s@macro-dialout-trunk:13] Macro("PJSIP/212-00000004", "outbound-callerid,3") in new stack
    -- Executing [s@macro-outbound-callerid:1] NoOp("PJSIP/212-00000004", "212") in new stack
    -- Executing [s@macro-outbound-callerid:2] NoOp("PJSIP/212-00000004", "") in new stack
    -- Executing [s@macro-outbound-callerid:3] NoOp("PJSIP/212-00000004", "off") in new stack
    -- Executing [s@macro-outbound-callerid:4] ExecIf("PJSIP/212-00000004", "0?Set(CALLERPRES(name-pres)=)") in new stack
    -- Executing [s@macro-outbound-callerid:5] ExecIf("PJSIP/212-00000004", "0?Set(CALLERPRES(num-pres)=)") in new stack
    -- Executing [s@macro-outbound-callerid:6] Set("PJSIP/212-00000004", "HOTDESCKCHAN=212-00000004") in new stack
    -- Executing [s@macro-outbound-callerid:7] Set("PJSIP/212-00000004", "HOTDESKEXTEN=212") in new stack
    -- Executing [s@macro-outbound-callerid:8] Set("PJSIP/212-00000004", "HOTDESKCALL=0") in new stack
    -- Executing [s@macro-outbound-callerid:9] ExecIf("PJSIP/212-00000004", "0?Set(HOTDESKCALL=1)") in new stack
    -- Executing [s@macro-outbound-callerid:10] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(name)=)") in new stack
    -- Executing [s@macro-outbound-callerid:11] Set("PJSIP/212-00000004", "ALLOWTHISROUTE=NO") in new stack
    -- Executing [s@macro-outbound-callerid:12] ExecIf("PJSIP/212-00000004", "0?Set(ALLOWTHISROUTE=YES)") in new stack
    -- Executing [s@macro-outbound-callerid:13] ExecIf("PJSIP/212-00000004", "0?Hangup()") in new stack
    -- Executing [s@macro-outbound-callerid:14] ExecIf("PJSIP/212-00000004", "0?Set(REALCALLERIDNUM=212)") in new stack
    -- Executing [s@macro-outbound-callerid:15] ExecIf("PJSIP/212-00000004", "0?Set(AMPUSER=212)") in new stack
    -- Executing [s@macro-outbound-callerid:16] GotoIf("PJSIP/212-00000004", "1?normcid") in new stack
    -- Goto (macro-outbound-callerid,s,20)
    -- Executing [s@macro-outbound-callerid:20] Set("PJSIP/212-00000004", "USEROUTCID=") in new stack
    -- Executing [s@macro-outbound-callerid:21] Set("PJSIP/212-00000004", "EMERGENCYCID=") in new stack
    -- Executing [s@macro-outbound-callerid:22] ExecIf("PJSIP/212-00000004", "0?Set(EMERGENCYCID=)") in new stack
    -- Executing [s@macro-outbound-callerid:23] Set("PJSIP/212-00000004", "TRUNKOUTCID=") in new stack
    -- Executing [s@macro-outbound-callerid:24] GotoIf("PJSIP/212-00000004", "1?trunkcid") in new stack
    -- Goto (macro-outbound-callerid,s,30)
    -- Executing [s@macro-outbound-callerid:30] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(all)=)") in new stack
    -- Executing [s@macro-outbound-callerid:31] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(all)=)") in new stack
    -- Executing [s@macro-outbound-callerid:32] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(all)=)") in new stack
    -- Executing [s@macro-outbound-callerid:33] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(all)=212)") in new stack
    -- Executing [s@macro-outbound-callerid:34] ExecIf("PJSIP/212-00000004", "0?Set(CALLERID(all)=212)") in new stack
    -- Executing [s@macro-outbound-callerid:35] Set("PJSIP/212-00000004", "TIOHIDE=no") in new stack
    -- Executing [s@macro-outbound-callerid:36] ExecIf("PJSIP/212-00000004", "0?Set(CALLERPRES(name-pres)=prohib_passed_screen)") in new stack
    -- Executing [s@macro-outbound-callerid:37] ExecIf("PJSIP/212-00000004", "0?Set(CALLERPRES(num-pres)=prohib_passed_screen)") in new stack
    -- Executing [s@macro-outbound-callerid:38] ExecIf("PJSIP/212-00000004", "0?Set(CALLERPRES(name-pres)=prohib_passed_screen)") in new stack
    -- Executing [s@macro-outbound-callerid:39] ExecIf("PJSIP/212-00000004", "0?Set(CALLERPRES(num-pres)=prohib_passed_screen)") in new stack
    -- Executing [s@macro-outbound-callerid:40] Set("PJSIP/212-00000004", "CDR(outbound_cnum)=212") in new stack
    -- Executing [s@macro-outbound-callerid:41] Set("PJSIP/212-00000004", "CDR(outbound_cnam)=Julian Felipe Hoyos Montoya") in new stack
    -- Executing [s@macro-dialout-trunk:14] GosubIf("PJSIP/212-00000004", "0?sub-flp-3,s,1()") in new stack
    -- Executing [s@macro-dialout-trunk:15] Set("PJSIP/212-00000004", "OUTNUM=573135566449") in new stack
    -- Executing [s@macro-dialout-trunk:16] Set("PJSIP/212-00000004", "custom=PJSIP") in new stack
    -- Executing [s@macro-dialout-trunk:17] ExecIf("PJSIP/212-00000004", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default)T)") in new stack
    -- Executing [s@macro-dialout-trunk:18] ExecIf("PJSIP/212-00000004", "0?Set(DIAL_TRUNK_OPTIONS=TM(confirm))") in new stack
    -- Executing [s@macro-dialout-trunk:19] Macro("PJSIP/212-00000004", "dialout-trunk-predial-hook,") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("PJSIP/212-00000004", "") in new stack
    -- Executing [s@macro-dialout-trunk:20] GotoIf("PJSIP/212-00000004", "0?bypass,1") in new stack
    -- Executing [s@macro-dialout-trunk:21] ExecIf("PJSIP/212-00000004", "1?Set(CONNECTEDLINE(num,i)=573135566449)") in new stack
    -- Executing [s@macro-dialout-trunk:22] ExecIf("PJSIP/212-00000004", "1?Set(CONNECTEDLINE(name,i)=CID:212)") in new stack
    -- Executing [s@macro-dialout-trunk:23] ExecIf("PJSIP/212-00000004", "0?Set(CONNECTEDLINE(name,i)=CID:(Hidden)212)") in new stack
    -- Executing [s@macro-dialout-trunk:24] GotoIf("PJSIP/212-00000004", "0?customtrunk") in new stack
    -- Executing [s@macro-dialout-trunk:25] ExecIf("PJSIP/212-00000004", "0?Set(DIAL_TRUNK_OPTIONS=)") in new stack
    -- Executing [s@macro-dialout-trunk:26] Set("PJSIP/212-00000004", "HASH(__SIPHEADERS,Alert-Info)=unset") in new stack
    -- Executing [s@macro-dialout-trunk:27] Dial("PJSIP/212-00000004", "PJSIP/573135566449@trunk-didww-outbound,300,Tb(func-apply-sipheaders^s^1,(3))U(sub-send-obroute-email^573135566449^3135566449^3^1642648372^Julian Felipe Hoyos Montoya^212)") in new stack
  == Begin MixMonitor Recording PJSIP/212-00000004
    -- PJSIP/trunk-didww-outbound-00000005 Internal Gosub(func-apply-sipheaders,s,1(3)) start
    -- Executing [s@func-apply-sipheaders:1] NoOp("PJSIP/trunk-didww-outbound-00000005", "Applying SIP Headers to channel PJSIP/trunk-didww-outbound-00000005") in new stack
    -- Executing [s@func-apply-sipheaders:2] Set("PJSIP/trunk-didww-outbound-00000005", "TECH=PJSIP") in new stack
    -- Executing [s@func-apply-sipheaders:3] Set("PJSIP/trunk-didww-outbound-00000005", "SIPHEADERKEYS=Alert-Info") in new stack
    -- Executing [s@func-apply-sipheaders:4] While("PJSIP/trunk-didww-outbound-00000005", "1") in new stack
    -- Executing [s@func-apply-sipheaders:5] Set("PJSIP/trunk-didww-outbound-00000005", "sipheader=unset") in new stack
    -- Executing [s@func-apply-sipheaders:6] ExecIf("PJSIP/trunk-didww-outbound-00000005", "1?Set(PJSIP_HEADER(remove,Alert-Info)=)") in new stack
[2022-01-19 22:12:52] ERROR[15108]: res_pjsip_header_funcs.c:410 remove_header: No headers had been previously added to this session.
    -- Executing [s@func-apply-sipheaders:7] ExecIf("PJSIP/trunk-didww-outbound-00000005", "0?Set(sipheader=<http://127.0.0.1>;info=unset)") in new stack
    -- Executing [s@func-apply-sipheaders:8] ExecIf("PJSIP/trunk-didww-outbound-00000005", "0?Set(sipheader=<http://127.0.0.1>unset)") in new stack
    -- Executing [s@func-apply-sipheaders:9] ExecIf("PJSIP/trunk-didww-outbound-00000005", "0?Set(PJSIP_HEADER(add,Alert-Info)=unset)") in new stack
    -- Executing [s@func-apply-sipheaders:10] EndWhile("PJSIP/trunk-didww-outbound-00000005", "") in new stack
    -- Executing [s@func-apply-sipheaders:4] While("PJSIP/trunk-didww-outbound-00000005", "0") in new stack
    -- Executing [s@func-apply-sipheaders:11] Return("PJSIP/trunk-didww-outbound-00000005", "") in new stack
  == Spawn extension (from-pstn, 3135566449, 1) exited non-zero on 'PJSIP/trunk-didww-outbound-00000005'
    -- PJSIP/trunk-didww-outbound-00000005 Internal Gosub(func-apply-sipheaders,s,1(3)) complete GOSUB_RETVAL=
    -- Called PJSIP/573135566449@trunk-didww-outbound
       > 0x318e320 -- Strict RTP learning after remote address set to: 46.19.209.17:32452
    -- PJSIP/trunk-didww-outbound-00000005 is making progress passing it to PJSIP/212-00000004
    -- PJSIP/trunk-didww-outbound-00000005 is making progress passing it to PJSIP/212-00000004
       > 0x318e320 -- Strict RTP switching to RTP target address 46.19.209.17:32452 as source
       > 0x3896f50 -- Strict RTP learning after remote address set to: 10.0.100.2:40018
       > 0x318e320 -- Strict RTP learning complete - Locking on source address 46.19.209.17:32452
  == Spawn extension (macro-dialout-trunk, s, 27) exited non-zero on 'PJSIP/212-00000004' in macro 'dialout-trunk'
  == Spawn extension (from-internal, 3135566449, 10) exited non-zero on 'PJSIP/212-00000004'
    -- Executing [h@from-internal:1] Macro("PJSIP/212-00000004", "hangupcall") in new stack
    -- Executing [s@macro-hangupcall:1] GotoIf("PJSIP/212-00000004", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,3)
    -- Executing [s@macro-hangupcall:3] ExecIf("PJSIP/212-00000004", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [s@macro-hangupcall:4] NoOp("PJSIP/212-00000004", "PJSIP/trunk-didww-outbound-00000005 montior file= /var/spool/asterisk/monitor/2022/01/19/out-3135566449-212-20220119-221252-1642648372.4.wav") in new stack
    -- Executing [s@macro-hangupcall:5] GotoIf("PJSIP/212-00000004", "0?skipagi") in new stack
    -- Executing [s@macro-hangupcall:6] AGI("PJSIP/212-00000004", "attendedtransfer-rec-restart.php,PJSIP/trunk-didww-outbound-00000005,/var/spool/asterisk/monitor/2022/01/19/out-3135566449-212-20220119-221252-1642648372.4.wav") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/attendedtransfer-rec-restart.php
    -- <PJSIP/212-00000004>AGI Script attendedtransfer-rec-restart.php completed, returning 0
    -- Executing [s@macro-hangupcall:7] Hangup("PJSIP/212-00000004", "") in new stack
  == Spawn extension (macro-hangupcall, s, 7) exited non-zero on 'PJSIP/212-00000004' in macro 'hangupcall'
  == Spawn extension (from-internal, h, 1) exited non-zero on 'PJSIP/212-00000004'
  == MixMonitor close filestream (mixed)
  == End MixMonitor Recording PJSIP/212-00000004

What is Dial(#include /etc/asterisk/extensions_override_fop2.conf line in /etc/asterisk/extensions_override_freepbx.conf?

seems wrong to me, if you try to do a core reload you should see something like

[2022-01-20 09:00:50] WARNING[24323]: config.c:1964 process_text_line: parse error: No category context for line 2 of /etc/asterisk/extensions_override_freepbx.conf

Remove the line, reload and make the call. The predial hook should look like this:

...
    -- Executing [s@macro-dialout-trunk:17] ExecIf("PJSIP/201-00000175", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default))") in new stack
    -- Executing [s@macro-dialout-trunk:18] ExecIf("PJSIP/201-00000175", "0?Set(DIAL_TRUNK_OPTIONS=M(confirm))") in new stack
    -- Executing [s@macro-dialout-trunk:19] Macro("PJSIP/201-00000175", "dialout-trunk-predial-hook,") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:1] AGI("PJSIP/201-00000175", "/var/lib/asterisk/agi-bin/randomcid.php") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/randomcid.php
...
1 Like

Excellent Stefano, everything is going well, thank you very much.

1 Like

Excuse me, I have to reopen the case, but I want something very specific, and that is that I need this random to apply only to one output route; because right now any exit route you create goes out there.
Thanks a lot.