Toggle navigation

Asterisk Common module (the Connector)


This module is the primary and base for the rest Asterisk related addons.

Its features are the following:

  • Adds a click to dial button to Partner form.
  • Adds controller to get partner name and set as caller ID name in Asterisk.
  • Adds a controller to get caller’s salesperson SIP channel and connect customers directly to their managers.
  • Adds a controller to organize differentiated telephone customer service by querying customer tags from Asterisk dialplan (e.g. put VIP customers in the VIP queue or in first place).

On the other side (Asterisk one) this addons addon requires the OdooPBX Agent to be setup and running.

Asterisk Setup

Asterisk Manager Interface (AMI)

You need is to allow the Agent to connect to your Asterisk server AMI port (usually 5038).

Here are the examples of required configuration options.


enabled = yes
webenabled = no ; Asterisk calls does not use HTTP interface
port = 5038
bindaddr =

displayconnects = yes

Important! For security reasons always use deny/permit options in your manager.conf. Change permit option to IP address of your Asterisk server if agent is not started on the same box. If you use Asterisk Base module it’s ok to put read=all and write=all. But if you use your own PBX manager (like FreePBX, etc) then you can just set minimal security settings:


Dialplan configuration

Here are some examples of integration levels.



; Set connection options for curl.
exten => _X.,1,Set(CURLOPT(conntimeout)=3)
exten => _X.,n,Set(CURLOPT(dnstimeout)=3)
exten => _X.,n,Set(CURLOPT(httptimeout)=3)
exten => _X.,n,Set(CURLOPT(ssl_verifypeer)=0)
exten => _X.,n,Return

; Partner's extension click2call e.g. +1234567890##101
exten => s,1,NoOp(DTMF digits: ${dtmf_digits})
same => n,ExecIf($["${dtmf_digits}" = ""]?Return)
same => n,Wait(${dtmf_delay})
same => n,SendDTMF(${dtmf_digits})
same => n,Return

;Set Caller ID name from Odoo
; Get caller ID name from Odoo, replace odoo to your Odoo's hostname / IP address
; Arguments:
; - number: calling number, strip + if comes with +.
; - db: Odoo's database name, ommit if you have one db or use dbfilter.
; - country: 2 letters country code, See
; If country code is omitted Asterisk Agent's Odoo account's country settings will be used for phonenumbers parsing.

exten => _X.,1,Gosub(sub-setcurlopt,${EXTEN},1)
;   You need to cut leading + on numbers incoming from trunks before passing it to get_caller_name.
exten => _X.,n,Set(CALLERID(name)=${CURL(${ODOO_URL}/asterisk_common/get_caller_name?number=${CALLERID(number)})})
exten => _X.,n,Return

; Get partners manager (salesperson) channel

exten => _X.,1,Set(manager_channel=${CURL(${ODOO_URL}/asterisk_common/get_partner_manager?number=${CALLERID(number)})})
exten => _X.,n,ExecIf($["${manager_channel}" != ""]?Dial(${manager_channel}/${EXTEN},60,t))
exten => _X.,n,Return

; Get partner's tags to create a special call routing (e.g. VIP queue)
; You can also get caller tags from Odoo with the following controller Here is an example:

; Partner tags
; VIP - tag name in this example.

exten => _X.,1,Set(CURLOPT(conntimeout)=3)
exten => _X.,n,Set(CURLOPT(dnstimeout)=3)
exten => _X.,n,Set(CURLOPT(httptimeout)=3)
exten => _X.,n,Set(CURLOPT(ssl_verifypeer)=0)
exten => _X.,n,Set(tags=${CURL(${ODOO_URL}/asterisk_common/get_caller_tags?number=${CALLERID(number)})})
exten => _X.,n,NoOp(Tags: ${tags})
exten => _X.,n,Set(match=${REGEX("VIP" ${tags})})
exten => _X.,n,NoOp(Match: ${match})
exten => _X.,n,Return(${match})

; Check VIP tag
exten => _X.,1,Gosub(partner-vip-tag-lookup,${EXTEN},1,VIP)
exten => _X.,n,GotoIf($["${GOSUB_RETVAL}" = "1"]?vip-queue,${EXTEN},1)

; Incoming call handling

exten => _X.,1,Gosub(sub-setcallerid,${EXTEN},1) ; Set partner's caller name
exten => _X.,n,MixMonitor(${UNIQUEID}.wav) ; Record call
exten => _X.,n,Gosub(sub-dialmanager,${EXTEN},1) ; Try to connect to manager
; Put here some login to handle if manager channel is busy for example put in the queue.
exten => _X.,n,Queue(sales)

exten => _X.,1,MixMonitor(${UNIQUEID}.wav) ; Activate call recording.
exten => _XXXX,2,Dial(SIP/${EXTEN},30) ; Local users calling
exten => _XXXXX.,2,Dial(SIP/provider/${EXTEN},30,TU(post-dial-send-dtmf) ; Outgoing calls pattern

Odoo setup

Do a database backup before installation or upgrade (just in case :-P).

See Odoo configuraiton.

Asterisk system account

During the installation process admin user is automatically added to Asterisk Admin security group.

Also during the installation process a new odoo account is created named asterisk with default password asterisk.

This account is used by default by the Agent to connect to your Odoo instance.

After installation it is strictly recommended to change default password the Agent connects to your Odoo and also set IP address of your Asterisk server to protect from unauthorized access.

Set account time zone

Asterisk sends call records in its server’s time zone. You should set asterisk account time zone in user’s preferences to value set in Asterisk server. To see time zone settings for account you should activate Odoo developer mode.

Configure users and groups

Map Odoo users with Asterisk user’s extensions. Users who use Asterisk Calls must have Asterisk Calls User permission.

For SIP users you can specify SIP alert-info header to enable auto answer feature. Check you SIP phone manuals for that.

After you mapped Odoo users with Asterisk extensions users can use click to call feature.

When you map Odoo user to Asterisk extensions in Asterisk Calls -> Users menu user is automatically added to Asterisk User group.

When you delete Asterisk user mapping Asterisk call permission is automatically removed from Odoo user.

Notice! After you change user extensions mapping reload the WEB client (press F5) to catch the change!