Accountcode value not flowing in extension_custom.conf?

I’m pretty sure I’m missing something obvious here. I’m trying to build a custom dialplan using accountcode. I tried few tests but any gosubif seemed to fail no matter what. I looked at logs and it seems that when I place a call accoundcode is always an empty variable but I don’t understand why.

Here is the current configuration (I stripped everything down to just the accountcode and being able to place a call):

exten => s,1,NoOp(ACCOUNTCODE is ${ACCOUNTCODE})
exten => s,n,Set(default_cid_ca=<ACTUAL_CID>) 
exten => s,n,NoOp(default_cid_ca is ${default_cid_ca})
exten => s,n,Set(CALLERID(num)=${default_cid_ca})
exten => s,n,Dial(PJSIP/${OUTNUM}@Twilio,30)

This is the log output (pasting likely relevant lines only):

4250	[2024-05-27 15:02:25] VERBOSE[8209][C-00000050] pbx.c: Executing [s@macro-outbound-callerid:37] ExecIf("PJSIP/98200-0000007a", "0?Set(CALLERID(all)=200)") in new stack
4265	[2024-05-27 15:02:25] VERBOSE[8209][C-00000050] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] NoOp("PJSIP/98200-0000007a", "ACCOUNTCODE is ") in new stack

This is the export of extensions from bulk handler (plz let me know if any other relevant column is needed):

Cross checked Extensions/Advanced:

Is there any other setting I need to enable for accountcode to be used? Is there anything overwriting this variable to nil? Any other pointer please?

You need to use ${CHANNEL(accountcode)}

1 Like

Thanks. I changed to:

exten => s,1,NoOp(accountcode w channel is ${CHANNEL(accountcode)})
exten => s,n,Set(CHANNEL(accountcode)=TEST) 
exten => s,n,NoOp(Sanity check w channel accountcode now is ${CHANNEL(accountcode)})

And got again an empty value?

14104	[2024-05-27 20:27:10] VERBOSE[21587][C-0000005d] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] NoOp("PJSIP/98200-00000095", "accountcode w channel is ") in new stack	
14105	[2024-05-27 20:27:10] VERBOSE[21587][C-0000005d] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:2] Set("PJSIP/98200-00000095", "CHANNEL(accountcode)=TEST") in new stack	
14106	[2024-05-27 20:27:10] VERBOSE[21587][C-0000005d] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:3] NoOp("PJSIP/98200-00000095", "Sanity check w channel accountcode now is TEST") in new stack

That log shows it working.

Sorry for the confusion. It’s not working as far as I can tell. The first row is the one that matters as it calls to chow the value available to the dialplan (i.e. using the value set on the dialing extension), which shows nothing. Line 2 and 3 I built only as sanity check so I could set a value (which was missing) so I could continue testing the rest of the configuration.

So essentially, configuration:

exten => s,1,NoOp(accountcode w channel is ${CHANNEL(accountcode)})


14104	[2024-05-27 20:27:10] VERBOSE[21587][C-0000005d] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] NoOp("PJSIP/98200-00000095", "accountcode w channel is ") in new stack	

Where are you setting the accountcode to begin with? It has to be set by something.

It’s set under extensions for each extension. I tried both via GUI (Extensions/Advanced) and Bulk handler (screenshots in first post).

What are you calling from? Sangoma Desktop client? Zulu?

Very interesting.

Running this:

exten => s,1,NoOp(accountcode is ${CHANNEL(accountcode)})

Shows this when called via Sangoma Talk (mobile app):

841	[2024-05-28 11:02:15] VERBOSE[13277][C-00000002] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] NoOp("PJSIP/200-00000002", "accountcode is TEST") in new stack

But shows this when called via Sangoma Desktop:

1014	[2024-05-28 11:03:07] VERBOSE[13556][C-00000003] pbx.c: Executing [s@macro-dialout-trunk-predial-hook:1] NoOp("PJSIP/98200-00000004", "accountcode is ") in new stack

So it appears that the issues has to be redefined as: when calling from Sangoma Desktop, accountcode does not seem to populate as variable in dialplan. Any idea why?

For my user case having a desktop app is a must have, so I really need to make this work.

It looks like PJSIP/98200 is callign rather than PJSIP/200, so it would make sense that being 98200 not having an assigned acocuntcode, it would be empty. But what is 98200 coming from?

I believe it is created automatically internally to allow the desktop client to work (WebRTC and non-WebRTC are incompatible from a configuration perspective) and presumably supposed to generally mirror the non-desktop client version. If accountcode isn’t mirrored, I would consider that a bug myself.


I am sure @lgaetz will correct me if I am wrong here but pretty sure extensions starting with 98 are legacy Zulu extensions.

Not sure about the accountcode part of the whole deal.

Zulu shadow extensions have a 99 prefix. Sangoma Phone desktop shadow extensions have a 98 prefix.

I’ve tested the accountcode field in the extension advanced settings, and it, works as expected for me.

In the GUI for extension 7002:

From the Asterisk CLI

# asterisk -x "pjsip show endpoint 7002" | grep accountcode
 accountcode                        : African Swallow
# asterisk -x "pjsip show endpoint 987002" | grep accountcode
 accountcode                        : African Swallow

and in the asterisk full log

    -- Executing [s@macro-dialout-trunk-predial-hook:1] NoOp("PJSIP/987002-00000003", "******************************** accountcode is African Swallow") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:2] MacroExit("PJSIP/987002-00000003", "") in new stack

    -- Executing [s@macro-dialout-trunk-predial-hook:1] NoOp("PJSIP/7002-00000001", "******************************** accountcode is African Swallow") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:2] MacroExit("PJSIP/7002-00000001", "") in new stack

Sangoma Connect module version

200 via CLI:

accountcode                        : TEST

98200 via CLI

accountcode                        :

Which reflects in the logs previously sent.

As this is “my” test extension, I likely created the desktop app access before assigning an accountcode for this one. Would it be possible that this is what caused it?

I just assigned my second desktop talk to a different user and his extension and the 98 extension accountcode match correclty.

I did test the following:

  • Changed accountcode via GUI for ext 200. Ext 98200 is now set correctly
  • Changed again accountcode via bulkhandler. ext 200 updates. Ext 98200 does NOT update

Since I indeed set and updated all accountcodes via bulkhandler this likely cause the issue for me. I’m on version

Will mark as solved but if anyone wants to test on their end and verify maybe it’s useful to others.

As of now my resolution is:

  • Set accountcode prior to enable Sangoma desktop for the extension/user
  • If accountcode needs to be updated for user with Sangoma Desktop, update via GUI
1 Like

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