Contact Us

Fort Smith AR:
479-478-3032
Toll Free:
866-658-0755
 
The image verification code you entered is incorrect.

Asttapi for Asterisk 1.2

I've patched Asttapi 0.10 to work with Asterisk 1.2. This requires things to be properly setup in your dial plan per the Asttapi 0.10 documentation, which admittedly is pretty poor. I'll try to simplify that a bit here.

Asterisk signals Asttapi through the UserEvent command in the dialplan. Asttapi needs to be informed of call progress as originated and incoming calls are progressing. Partially a problem exists that as the calls are connected, two unique IDs are generated which means that some of the commands need to pass the old unique ID back to asttapi as well. To setup Asttapi properly in the dial plan, you need the following:

Prior to the Dial() command, you need to send some UserEvents to Asttapi to let it know there's a call coming into your phone. I've modified my stdexten macro to look like this:


exten => s,1,UserEvent(TAPI|TAPIEVENT: LINE_NEWCALL ${ARG2})
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_OFFERING)
exten => s,n,UserEvent(TAPI|TAPIEVENT: SET CALLERID ${CALLERID})
exten => s,n,UserEvent(TAPI|TAPIEVENT: LINE_CALLINFO LINECALLINFOSTATE_CALLERID)

exten => s,n,Dial(${ARG2},20,rtM(tapi^${UNIQUEID}|${ARG2}))
exten => s,n,Goto(s-${DIALSTATUS},1) ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
;exten => s,104,Goto(s-BUSY,1)

exten => s-NOANSWER,1,Voicemail(u${ARG1}) ; If unavailable, send to voicemail w/ unavail announce
exten => s-NOANSWER,2,Goto(default,s,1) ; If they press #, return to start

exten => s-BUSY,1,Voicemail(b${ARG1}) ; If busy, send to voicemail w/ busy announce
exten => s-BUSY,2,Goto(default,s,1) ; If they press #, return to start

exten => _s-.,1,Goto(s-NOANSWER,1) ; Treat anything else as no answer

exten => a,1,VoicemailMain(${ARG1}) ; If they press *, send the user into VoicemailMain

exten => h,1,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_IDLE)

This sends both a dial event and a hangup event to asttapi to let it know an incoming call is progressing. Notice in the Dial command for stdexten, we also call a macro, tapi, that sends additional call progression information after the call is connected. The macro looks like this:


[macro-tapi];
exten => s,1,UserEvent(TAPI|TAPIEVENT: [~${ARG1}&${ARG2}] LINE_CALLSTATE LINECALLSTATE_CONNECTED)
exten => s,2,UserEvent(TAPI|TAPIEVENT: [~${ARG1}&!${ARG2}] LINE_CALLSTATE LINECALLSTATE_HANGUP)

For outbound calls, we need a macro that also properly signals asttapi. I've modified my trunklocal and trunkld macros to call another macro, which was originally designed to fall back to VoIP trunks if all the analog trunks were busy, but I'll show you the excerpt that signals asttapi that should be relevant. Replacing the Dial() command in trunklocal and trunkld with this macro should be sufficient:


[macro-fallback]
; ${ARG1} : Trunk to call out on
; ${ARG2} : Number to call
; ${ARG3} : Time to let ring
; ${ARG4} : Dial Options

exten => s,1,UserEvent(TAPI|TAPIEVENT: LINE_NEWCALL ${CHANNEL:0:7})
exten => s,2,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_DIALTONE)
exten => s,3,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_DIALING)
exten => s,4,UserEvent(TAPI|TAPIEVENT: LINE_CALLSTATE LINECALLSTATE_PROCEEDING)
exten => s,5,Dial(${ARG1}/${ARG2},${ARG3},${ARG4}M(tapi^${UNIQUEID}|${CHANNEL:0:7}))

Note in the Dial() command, the macro called sends ${CHANNEL:0:7} as the second parameter. This is to signal to asttapi that we're on the right line. My asttapi line is set as SIP/101, but asterisk ${CHANNEL} holds something like SIP/101-asdf, so I limit the output to 7 characters. Make sure to adjust your settings inside the macro and inside asttapi appropriately. The line inside asttapi and inside the macro is arbitrary, and confusingly enough inside the original asttapi documentation, he uses hard coded values here, which would only work in testing and isn't scalable.

Also, on originated calls, whatever context they originate in or the default context, you need a hangup extension like I setup in the stdexten macro above.

To use the latest asttapi build, you'll need to install asttapi 0.10 from here. Then download the asttapi.tsp file from here and place it in your system32 directory and reboot (optionally, you can stop outlook and run a net stop tapisrv from cmd and probably be fine, but don't send me an email until you've rebooted :) ).

Let me know how it works for you. Sorry the documentation is poor, I'm looking for help there, I don't have time to write it well.

Update: Source is available here

Submitted by Cygnus (not verified) on July 23, 2008 - 10:17am.

Hi!

I have followed your configuration using a Outlook 2007 client with Identapro on Windows XP. I can initiate outgoing calls, but incoming calls are not shown in the identapro debug log.

I have verified that asterisk is sending out the incoming phone event through the manager interface on port 5038. But on the astapi side i do not see any incoming call. Any ideas? I can send you a tcpdump on port 5038 of the incoming call.

Greetings Torge

Submitted by Cygnus (not verified) on July 23, 2008 - 11:08am.

Hi!

This works now for me. Thanks for providing information on Asterisk 1.2 and the corresponding patched file.

One should note that if you use a different line name and user channel the above given extensions do not work.

The dial line for incoming calls should then read:

exten => s,n,Dial(${ARG1},20,rtM(tapi^${UNIQUEID}|${ARG2}))

when the macro is called in the following way:Macro(stdexten,SIP/sipuserchannel,lineid)

Greetings Torge

Submitted by Anonymous (not verified) on September 8, 2008 - 5:35am.

Hi

Thanks for the info.
I have installed the patch and asttapi OK.

But I cannot work out what to put in the extensions.conf to notify ASTTAPI. It doesnt make much sense.

My standard context for incoming calls is:

[incoming]
exten=>039012xxxx,1,Dial(SIP/clientphone,30,r)

How do I adapt the required context into the above string?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.
More information about formatting options Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.