CID-Superfecta: Outbound CallerID (or Phonebook) Lookup for outgoing Calls

Some phones do not show any names, when you call somebody, e.g. cisco phones. I just recently found this
http://incrediblepbx.com/dialout-cnam.txt
and this

I created a scheme in CID-Superfecta (CID-match X.) with the name “outgoing”, created a new superfecta.agi in admin/modules/superfecta/agi (rights!) and added most of the code from the link above to extensions_override_freepbx.conf.
It works on a Cisco 8961. It doesnt work on my Cisco 7975 though.
Once connected the Cisco shows me the name and the number. Finally I have names in my outgoing-calls list on my Cisco 8961!!! The lookup sources you can adjust in Superfecta.
CDR reports shows the name of outgoing calls too.
I am no pro…so it might be a terrible solution…yet, if there comes no solution with freePBX…it is the only solution :wink:
It might work with most (newer) IP phones. My Sangoma 705s displays the name, yet it has a built-in LDAP-lookup anyway. So this dirty workaround is required for non-Sangoma-phones only.

superfecta-out.agi

<?php
$restrict_mods = true;
include '/etc/freepbx.conf';
$agidir = FreePBX::Config()->get('ASTAGIDIR');
require_once $agidir."/phpagi.php";

$base_dir = dirname(dirname(__FILE__));
$agi = new AGI();
$scheme_return = $agi->get_variable("CIDSFSCHEME");

if (($scheme_return['result']) && (trim(base64_decode($scheme_return['data'])) != '')) {
	$scheme = base64_decode($scheme_return['data']);
} else {
	$scheme = 'base_outgoing';
}

if ($scheme == 'ALL|ALL') {
	$sn[1] = 'ALL';
} else {
	$sn = explode("_", $scheme, 2);
}

if (!empty($agi->request['agi_callerid'])) {
	$agi->verbose("Executing Scheme..");
	$superfecta = FreePBX::Superfecta();
	$superfecta->setAgi($agi);
	$callerid = $superfecta->execute($sn[1], $agi->request);
	$dest = $superfecta->getDest();
	if(!empty($dest)) {
		$agi->verbose("CID Determined to be: '" . trim($callerid) . "'");
		$agi->verbose("SPAM Score was ".$superfecta->getSpamScore());
		$agi->verbose("Sending call to ".$dest[0]);
		$agi->set_variable("CALLERID(name)", trim($callerid));
		$agi->set_variable("lookupcid", trim($callerid));//because we could bounce back here
		$agi->goto_dest($dest[0], $dest[1], $dest[2]);
		exit();
	}
	if(!empty($callerid)) {
		$agi->verbose("CID Determined to be: '" . trim($callerid) . "'");
		$agi->verbose("Attempting to set lookupcid");
		$agi->set_variable("lookupcid", trim($callerid));
		exit();
	}
} else {
	$agi->verbose("Not a valid number");
}

extensions_override_freepbx.conf

[macro-dialout-trunk-predial-hook]
    exten => s,1,Noop(*** ${DIAL_NUMBER} ***)
    exten => s,n,Set(num2find=${DIAL_NUMBER})
    exten => s,n,Set(OrigCID=${CALLERID(num)})
    exten => s,n,Set(OrigCNAM=${CALLERID(name)})
    exten => s,n,Set(CALLERID(num)=${num2find})

    exten => s,n,Set(CURLOPT(httptimeout)=7)
    exten => s,n,Set(lookupcid=${num2find})
    exten => s,n,Set(CALLERID(name)=${OrigCNAM})
    exten => s,n,AGI(/var/www/html/admin/modules/superfecta/agi/superfecta-out.agi)
    exten => s,n,Set(CALLERID(name)=${lookupcid})

    exten => s,n,NoOp(*** ${CALLERID(name)} ***)
    exten => s,n,Set(CDR(accountcode,r)=${CALLERID(name)})

    exten => s,n,Set(CONNECTEDLINE(num,i)=${DIAL_NUMBER})
    exten => s,n,Set(CONNECTEDLINE(name,i)=${lookupcid})  ; for CallerID Superfecta
    exten => s,n,Set(CALLERID(num)=${OrigCID})
    exten => s,n,Set(CALLERID(name)=${OrigCNAM})
    exten => s,n,MacroExit()

There is a module that does this as well, no custom dialplan required:

1 Like

This is great!!! Thanks :slight_smile:
…but now I have a “unsigned module” error in freePBX :frowning: :wink:

awesome…thanks a lot lgaetz!!!
Superfecta is the main reason why I still use freePBX! I don’t know of any other distro, which includes such a versatile tool!

Not important…but there is a typo in the description…dispalay

As a third party module, it’s unsigned. You are free to sign it yourself, or just dismiss the notice.

I used the less common Canadian spelling. Pull requests on Github cheerfully accepted :grinning:

1 Like

just to let you know…
I installed the module on another (completely new, 14.0.5.25) freePBX distro and got an exception error (freePBX GUI), when I opened the out-cnam-settings.

It’s somewhere here in the code (I removed it and now it works)
page.outcnam.php

// check to see if user has automatic updates enabled in FreePBX settings
$cm =& cronmanager::create($db);
$online_updates = $cm->updates_enabled() ? true : false;

// check dev site to see if new version of module is available
if ($online_updates && $foo = outcnam_vercheck()) {
	print "<br>A <b>new version of this module is available</b> from the <a target='_blank' href='http://pbxossa.org'>PBX Open Source Software Alliance</a><br>";
}

Again, thanks a lot for this “showing name on outgoing calls” feature for cisco and any other phones. It works now on both types of my Ciscos…7975 and 8961…freePBX 13 and with minor revision on freePBX 14.0.5.25 :wink:

1 Like

now fixed in ver .0.0.4

1 Like

Jesus!!! happy0045

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.