Sep
23
2017
0

How to setup a Centurylink IQ SIP Trunk for Asterisk

Centurylink IQ architecture

I recently struggled to install a Centurylink SIP trunk.  Our rep could only provided us with Cisco configuration instructions.  From there we had to decipher the appropriate settings in Asterisk.  If you are reading this post you are probably in serious trouble right now.  Don’t worry!  Take a deep breath and keep reading!

 This is for Vanilla Asterisk 1.8.x.  I will cover sip.conf and extensions.conf examples.  The reference system is CentOS 7 paired with Asterisk 1.8.28.  This tutorial assumes you have working knowledge of Asterisk and the core configuration files.

Goals of the Post:

  • Configure Centurylink IQ SIP Trunk (sip.conf)
  • Configure Inbound/Outbound dialing (extensions.conf)
  • Set Hosts Mapping (/etc/hosts)

 

(more…)

Dec
09
2011
1

Asterisk: Holiday Macro

Below is an example of a macro that checks to see if the ‘holiday’ menu is enabled.  I also added extension 2970, a ‘one touch’ utility to enable/disable the holiday macro.  Remember to create a ‘holiday_disabled.wav’ that literally says, “Holiday menu disabled”.  To rercord a message simply disable and enable the utility again.  Enjoy!

 

 

[macro-holiday]

;Check if holiday message set

;Check if it is a holiday
exten => s,1,NoOp(Check for Holidays)
exten => s,n,Answer()
exten => s,n,set(HOLIDAY=${DB(closed/1)})
exten => s,n,NoOp(${HOLIDAY})
exten => s,n,gotoIf($[“${HOLIDAY}” = “1”]?main-holiday,s,1)   ; Custom Holiday

;Otherwise
exten => s,n,gotoiftime(08:00-19:00,mon-fri,*,*?${ARG1},s,1) ; Main Operating Hours
exten => s,n,goto(${ARG2},s,3)

;===============================================================

[from-pstn]

;
;
; usage: macro(holiday,ARG1,ARG2)
;
; argument one and two are that day and night menu
;
; Some DID

exten => 12134974061,1,macro(holiday,main-day,main-night)

[utilities]

;————————————————–
; One touch Record/Set Holiday Closed Message
;
exten => 2970,1,NoOp(============ Set Holiday Message ==============)
;exten => 2970,1,authenticate(5678)
exten => 2970,n,Wait(1)

; check to see if holiday message is set
exten => 2970,n,set(HOLIDAY=${DB(closed/1)})
exten => 2970,n,NoOp(${HOLIDAY})
exten => 2970,n,NoOp(${HOLIDAY})
exten => 2970,n,NoOp(${DB(closed/1)})
exten => 2970,n,gotoIf($[“${HOLIDAY}”=”1”]?utilities,2970(disable),1:utilities,2970(enable),1)

; if disabled record a new greeting
exten => 2970(enable),1,Record(en/custom/holiday_message:gsm)
exten => 2970(enable),n,Wait(1)
exten => 2970(enable),n,set(DB(closed/1)=1)
exten => 2970(enable),n,Playback(en/custom/holiday_message)
exten => 2970(enable),n,wait(1)
exten => 2970(enable),n,Hangup

; disable the holiday message and alert the caller

exten => 2970(disable),1,set(DB(closed/1)=0)
exten => 2970(disable),n,Playback(en/custom/holiday_disabled)
exten => 2970(disable),n,Hangup

Aug
25
2009
60

How to Query a Database from MySQL with Asterisk 1.6 ODBC

I’ve been administering Asterisk servers for many years and everyday I’m learning something new.  As the size of the projects have gotten bigger, so have the demands of my customers.  One common request is database integration.  In the past I’ve used external AGI scripts to run database queries to return values to Asterisk.  But more recently I’ve been avoiding AGI in favor of direct access SQL.  This is achieved by building ODBC modules into Asterisk at build time.  Let me tell you, it’s worth it!

Asterisk & ODBC provide the ability to easily update and retrieve data by defining SQL statements as special variables that can be called from the dial plan.  For instance, we could bill ‘long distance’, take credit cards and let Asterisk access other types of information.  In my tutorial we will configure Asterisk to dial a variable that represents a SQL statement.  This could also be done by calling an AGI script, but why do the extra work?

This ‘How to’ is specifically geared towards MySQL.  However, if you set the up the ODBC driver correctly you can use any SQL server you like.  Which leads me to my next thought, before you start, make sure ODBC is set up correctly.  Follow one of my previous tutorials:

configure Linux ODBC for MS-SQL

configure Linux ODBC for MYSQL

Once you do this we are ready to continue…

The goals of this post:

– create MySQL table with example data
– configure res_odbc.conf
– configure func_odbc.conf
– configure extensions.conf for query

(more…)

May
04
2009
1

extensions.conf – Asterisk 1.4.23 and Queuemetrics 1.5.2

[general]

static=yes
writeprotect=no

[bogon-calls]

exten => _x.,1,Congestion

[macro-stdexten]
;
;for dialing internal extensions

exten => s,1,Set(dynext=${DB(dynext/${ARG1})})
exten => s,n,NoOp(${dynext})
exten => s,n,NoOp(${LEN(${dynext})})
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “7”]?s,100)
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “10”]?s,100)
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “11”]?s,100)
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “6”]?s,200) ; Calls 6-digit Extension
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “0”]?s,300) ; Calls 6-digit Extension
exten => s,n(dial),Dial(SIP/${dynext},20,twW) ; Ring the interface, 20 seconds maximum
exten => s,n,Goto(s-${DIALSTATUS},1) ; Jump based on status
exten => s,100,Dial(ZAP/g1/${dynext},20,twW) ; Ring the interface, 20 seconds maximum
exten => s,101,Goto(s-${DIALSTATUS},1) ; Jump based on status
exten => s,200,Goto(from-sip,${dynext},1); Calls 6-digit Extension
exten => s,300,Set(dynext=${ARG1})
exten => s,301,Goto(dial)

exten => s-BUSY,1,Voicemail(b${ARG1}) ; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Hangup
exten => s-NOANSWER,1,Voicemail(u${ARG1}) ; If unavailable, send to voicemail
exten => s-NOANSWER,2,Hangup
exten => _s-.,1,Goto(s-NOANSWER,1) ; Treat anything else as no answer

[from-sip]

include => test
include => from-internal

[test]

exten => 1234,1,agi(matts-test.agi)
exten => 1234,2,wait(2)
;exten => 1234,n,voicemail(8888)
exten => 1234,n,hangup
[from-internal]

;Standard Internal Extensions

exten => _888X,1,Macro(stdexten,${EXTEN},sip/${EXTEN})
exten => _888X,2,Hangup

; Add Member SIP/${CALLERID(num)}
exten => 2000,1,Answer
exten => 2000,n,VMauthenticate(${CALLERID(num)}@default)
exten => 2000,n,AddQueueMember(savelono-support|SIP/${CALLERID(num)}|1|)
exten => 2000,n,Playback(agent-loginok)
exten => 2000,n,Hangup

; Remove Member – Dynamic Agent SIP/${CALLERID(num)}
exten => 2001,1,Answer
exten => 2001,n,VMauthenticate(${CALLERID(num)}@default)
exten => 2001,n,RemoveQueueMember(savelono-support|SIP/${CALLERID(num)})
exten => 2001,n,Playback(agent-loggedoff)
exten => 2001,n,Hangup

exten => 5000,1,goto(test-queue,s,1)

[savelono-queue-out]

include => from-internal

[test-queue]

exten => s,1,Queue(savelono-support)
exten => s,2,hangup

Apr
22
2009
0

Asterisk: Creating an Extension to Logout Agents from CallerID

I told a customer for the company I for that I would figure out how to logout agents by CID(Caller ID). So I figured, why not kill two birds with one stone. Today we will create a single Queue, Agent, and dial plan to accomplish this goal. I’m using Asterisk 1.4, Fedora 10 and a Polycom IP SIP phone for my demonstration purposes.

When I started this project four hours ago, I thought I would google my way to another successful blog post(and happy customer), but no…  logging out agents in Asterisk is very unintuitive.  The agentcallbacklogin utility has the exact same prompts for logging in as out.  AgentCallbackLogin (when initiated, from the dial plan)  asks for three things, agent, agent password, and call back number.  To eliminate all these prompts I’m using the ‘$CallerID(num)’ variable to automatically answer the agent and call back number.  So the user 8888 dials ‘1000’ and and AgentCallbackLogin assumes he is AGENT/8888 with a password of ‘8888’.

from /etc/asterisk/extensions.conf

exten => 1000,1,AgentcallbackLogin(${CALLERID(num)}||${CALLERID(num)}@savelono-queue-out)
exten => 1000,n,hangup

(more…)

Apr
22
2009
1

extensions.conf – agent logoff example

[general]

static=yes
writeprotect=no

[bogon-calls]

exten => _x.,1,Congestion

[macro-stdexten]
;
;for dialing internal extensions

exten => s,1,Set(dynext=${DB(dynext/${ARG1})})
exten => s,n,NoOp(${dynext})
exten => s,n,NoOp(${LEN(${dynext})})
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “7”]?s,100)
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “10”]?s,100)
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “11”]?s,100)
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “6”]?s,200) ; Calls 6-digit Extension
exten => s,n,GotoIf($[“${LEN(${dynext})}” = “0”]?s,300) ; Calls 6-digit Extension
exten => s,n(dial),Dial(SIP/${dynext},20,twW) ; Ring the interface, 20 seconds maximum
exten => s,n,Goto(s-${DIALSTATUS},1) ; Jump based on status
exten => s,100,Dial(ZAP/g1/${dynext},20,twW) ; Ring the interface, 20 seconds maximum
exten => s,101,Goto(s-${DIALSTATUS},1) ; Jump based on status
exten => s,200,Goto(from-sip,${dynext},1); Calls 6-digit Extension
exten => s,300,Set(dynext=${ARG1})
exten => s,301,Goto(dial)

exten => s-BUSY,1,Voicemail(b${ARG1}) ; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Hangup
exten => s-NOANSWER,1,Voicemail(u${ARG1}) ; If unavailable, send to voicemail
exten => s-NOANSWER,2,Hangup
exten => _s-.,1,Goto(s-NOANSWER,1) ; Treat anything else as no answer

[from-sip]

include => test
include => from-internal

[test]

exten => 1234,1,agi(matts-test.agi)
exten => 1234,2,wait(2)
;exten => 1234,n,voicemail(8888)
exten => 1234,n,hangup

[from-internal]

;Standard Internal Extensions

exten => _888X,1,Macro(stdexten,${EXTEN},sip/${EXTEN})
exten => _888X,2,Hangup

;Logon
exten => 1000,1,AgentcallbackLogin(${CALLERID(num)}||${CALLERID(num)}@savelono-queue-out)
exten => 1000,n,hangup

;Logoff – best alternative I’ve found so far
;could be better with additional logic

exten => 1001,1,System(/usr/sbin/asterisk -rx “agent logoff Agent/${CALLERID(NUM)}”)
exten => 1001,n,RemoveQueueMember(savelono-support|Agent/${CALLERID(NUM)})
exten => 1001,n,Playback(agent-loggedoff)
exten => 1001,n,Playback(auth-thankyou)
exten => 1001,n,Hangup

;Logoff this way works but is not very intuitive because you
;have to hit the # key when prompted for a dial back extension
;it really doesn’t make sense to endusers
;
exten => 1002,1,AgentcallbackLogin(${CALLERID(num)}||)
exten => 1002,n,hangup

[savelono-queue-out]

include => from-internal