Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Action Scripts expose an api that help you interact with the telephone system.

class BaseRouteStep

When you create a new Action Script of type Route Step a default implementation will be created. Your Action Script will be derived from the base class 'BaseRouteStep'.

As Noojee PBX is based on Asterisk its worth understanding that calls are passed into Routing using fast AGIĀ using the Asterisk-Java library.

http://asterisk-java.org/

https://github.com/asterisk-java/asterisk-java

The main way of controlling a call is via AGI commands. You can issue AGI commands by calling the getAgi() method on the BaseRouteStep class.

The base class has a number of other useful methods that make it easy to write a Route script.

The core system ships with a large number of Route Scripts which you can reference as examples.

Building a UI

A Route Step also allows you to build a UI for an end user to configure your specific Route step.

The set of UI components are defined in:

au.com.noojee.actionscript.api.v1.args.*

It is considered good practice to define each of the UI fields as Java fields at the top of you class.

The fields MUST bee added to the list of fields returned by the 'BaseRouteScript:getFields()' method.

Debugging

There are a number of tools available to help you debug your Route Steps.

You can seed your code with call to the inbuilt logger by calls to:

To see the log output and to test your Scripts use the 'Logging and Testing' tab availble for each Route Step on the Route page.


To run a test, set the Logging Level, Click the Save button and the Click the Test button.

Logging and Testing

The Logging and Testing panel is Noojee's gift to you. (We aren't afraid to admit that we are almost gods when it comes to this sort of thing.Ā (smile)Ā ).

But seriously, the Logging and Testing console is is really powerful and makes it easy to test Routes in general as well as your Custom Routes scripts.

The logging and testing console allows you to originate a call into a specific route or 'capture' a call into a specific route.

Context

The Route context to originate the call into or capture calls that enter. This works with the Number to Dial to define the complete target. (i.e. you can have the same Target

Target

You can enter a phone number or more commonly a Route 'Target' that you want to dial into for testing.


Originating a call (Dial Button)

When building a new Route or Route Script you will want to use the 'Dial' button to originate calls into you route.

The 'Dial' button rings you handset (you MUST have entered a valid extension no. when you logged into Noojee).

When you answer the call the route selected in 'Number to Dial' is run.

Any log output is sent to the Logging and Testing console.



System Route Variables:

Routes provide a number of default system variables which can be access to determine information pertaining to the current call or the system as a whole. The following variables can be access by calling getVariable(variableName).

Please note that these variables are readonly and as such you can't update them.

The system may update some of these Route Variables as a call progresses through a route.

Variable NameDescriptionScope
nj.DeliveredTo

When a call is initially routed or Gosub is called the value in nj.Target is used to pattern match against possible targets in the context.Ā  When a specific target is selected 'nj.DeliveredTo' is set to the value of the Target that matches.

e.g. nj.Target might be: 03 8320 8100 but nj.DeliveredTo might be 03 XXXX XXXX.

Gosub
nj.DialedNo

The number that was dialed to cause the current call. For an inbound call this will be the DID for an outbound call this will be the no. dialed from the staff members handset.

The dialed no. will not change over the life of a call.

Call
nj.Realm

Set by the Trunk through which the call entered the system. Even calls from internal extensions (handsets) enter Routes via a Trunk.

The Realm is used to determine the direction of the call. The system uses the Source realm and theĀ Delivered To realm to determine the direction of the call. The systems ability to determine a calls direction is important when determining whether a call should be recorded for an Account as well as for general reporting purposes.

It should be noted that superficially it would appear to be quite easy to determine a calls direction however in practices it can be quite complicated as a call can actually changed direction mid way through the call.

Realms are INTERNAL,EXTERNAL

Call
nj.Direction

Reflects the direction of the call.

The direction of a call is not as simple as it might look as a call can changed directions as the call progresses.

e.g. an inbound call is re-routed to an external call. It then becomes a 'PASS_THRU' call.


  • INTERNAL - call between two handsets
  • OUTBOUND - call to an outside number
  • PASS_THRU - a call that has passed into then out of the system.
  • INBOUND - a call from an external party into the system.

nj.SourceNo

Set by the core routing each time a call is originated. For inbound calls this is the caller id, for calls dialed from a handset this is the handset extension no.


Call

nj.Target

The target typically starts out with the same value as the 'nj.DialedNo' but unlike nj.DialedNo the variable nj.Target is updated each time the Gosub command is called. nj.Target is updated to match the second argument of the Gosub command (context, target).

When a Gosub returns it will reset the nj.Target variable to the value it was before Gosub was called.

Gosub



Target

A Target can be a phone no., a pattern or an alphabetical literal.
A Target pattern is a used to match Targets consisting of digits only.

SourceNo

Set by core routing each time a call is originated. For inbound this is the caller id, for calls dialed from a handset this is the handset extension no.

DialedNo

- called by the core routing logic when a call first enters the system. Normally this wouldn't be modified by a script unless the trunk provider provides a badly formatted no. hin which you may want to re-reformat it using the rewrite action.

For most systems the dialed no. doesn't change during the life of a call.

setCurrentTarget(target)

Called by the core routing logic whenever a call matches a route target including when the call enters the very first route.

The routed no is essentially updated each time the call transition into a new route Target (the Gosub step is the main method of changing the current Target).

Documentation

The Action Script UI contains builtin Ā documentation. Click the 'Open Java Docs' button and a new browser tab will open with the full docs.


BaseScriptRoute

The following provides a high level overview of the BaseScriptRoutes. Refer to the above noted Java doc for additiona details.

Overview:

MethodArgumentsReturn typeComments
dialTrunk trunk, String phoneNo, String options, int timeoutvoid

Dials the given phone number using the selected trunk.

trunk - the trunk to dial over

phoneNo - the phone number to dial

options - any asterisk dial options required.

timeout - the time (in seconds) to wait for the dial to connect.

conferenceString roomNo, String pin, String options

roomNo - The conference room to pass the call to. If the conference room doesn't exist it will be dynamically created.

PIN - the pin number used to control access to the conference room. Pass a blank string if you don't want a PIN assigned to the conference room.

options - any valid asterisk conference room options.

getAccountFromIdLong idAccountLook up an account using the id passed in. The Account object returned is detached from the database.
getAgivoidBaseAgiScriptReturns the BaseAgiScript, this allows direct agi calls to be made against the channel
getArgAsBooleanString fieldNameBooleanTakes a fieldName for the Script and returns the fields value as a Boolean.
getArgAsIntString fieldNameIntegerTakes a fieldName for the Script and returns the fields value as an Integer.
getArgAsLongStringĀ fieldNameLongTakes a fieldName for the Script and returns the fields value as a Long.
getArgAsStringStringĀ fieldNameStringTakes a fieldName for the Script and returns the fields value as a String.
getBMMFileNameFromIdLong idStringReturns the name of the BMM audio file without the file extension. This is suitable for passing to the 'playback' command which assumes the file doesn't has a file extensions.
getChannelVariableString nameStringGets the value of an Asterisk channel variable.
getDialedNoVoidStringReturns the number that was dialed to trigger this call route. For inbound calls this will be the DID, for outbound calls it will by the number dialed from the handsets.
getDirectionVoidau.com.noojee.callrouting.CallDirection

Returns the CallDirection enum indicating which direction the call is flowing in. CallDirection has the following possible values:

CallDirection.INBOUND

CallDirection.PASS_THRU - not used on most systems

CallDirection.INBOUND

getHandsetFromIdLong idHandset

Looks up the Handset indentified by id and returns a detached entity

getPhoneNoForAccountIdLong idStringReturns the phone currently attached to the given account.
getQueueFromIdLong idQueueLooks up the Queue indentified by id and returns a detached entity
getRoutedNoNoneStringThe current RoutedNo. See setRoutedNo() for details.
getSourceNoNoneStringReturns the source phone no. that originated the call. For an inbound call it is the callers caller id, for an outbound call it is the handsets extension no.
getSourceRealmNoneRealmReturns the Realm for the current call. When any call enters the system a Realm is set to describe how the call entered the system. The two Realms are Realm.INTERNAL and Realm.EXTERNAL




getSystemVariableString keySystemEntityreturns a detatched system variable entity for the given key.
getTrunkDialStringFromIdLong idString

Returns the Dial String for the trunk whose primary key is id.

getTrunkFromIdLong idTrunkReturns the Trunk object whose primary key is id.
getVariableString nameStringGets the value of the Route Script variable with the given name. Route Script Variables have a life cycle linked to the underlying call. Route Script Variables are much faster than Channel Variables.
getVoiceMailBoxFromIdLongVoiceMailBoxreturns the VoiceMailBox entity for the given id.
gosubRouteContext context, String targetvoidSend the call to the given context with the given target as the 'deliveredTo' number.
queueQueue queue, String options, int timeoutvoid

queuename - the name of the queue to send the call to

options - any valid asterisk queue options

timeout - the amount of time to wait for the call to be connected before exiting the queue.

The deliveredTo number gets set to the Agents extension when the call is answered by an agent.

setChannelVariableString name, String valueVoidSets the value of an Asterisk channel variable.
setDialedNoString numberVoidAllows the dialedNo to be modified by a script.
setSource

String number, Realm realm

VoidSet the number the call came from and the realm (INTERNAL/EXTERNAL ETC)
setVariableString name, String valueVoidSets the value of the Route Script variable with the given name creating it if it doesn't already exists.
Ā substituteVariablesString messageStringParses the passed message looking for any encoded Route variable names and replacing the encode variable name with the variables value. The encoding scheme is of the form: ${variablename}
startRecordingboolean force, String tagVoidUnconditionally starts recording the current call. If recording is already running then a new leg is started.
stopRecordingboolean forceVoidStops recording.
voicemailString vmbox, String optionsvoid

Connects the caller to the given voicemail box.

vmbox - the voicemail box no.

options - any valid asterisk voicemail box options.

variableExistsString nameBooleanreturns true if the variable with the given name exists and is non-zero in length.




  • No labels