Helpful hints when programming Asterisk telephony apps
I do not pretend that these are in any particular order, but given
Asterisk's many features, I find this kind of aide memoire helpful.
-
Where the heck do you 'program' behavior into this beast?
Short answer: /etc/asterisk/extensions.conf is what you are looking for
in terms of so-called 'extension' programmability.
What does that mean? here is the quick and sweet:
You list a bunch of 'extensions' under an 'extension context' like
this:
[mycontext]
exten => s,1,dothis
exten => s,2,dothat
exten => s,3,dotheother
The terminology is: 'extension context' mycontent has an extension 's'
that has priority 1, 2, and 3; each priority does something, typically
conducted in extension 'cmds' as listed on wiki.
It's kind of primitive, because there are crazy little things like
conditionals that either branch to n+1 or n+101 on some condition. It's
sort of macro assembly-language-ish (the program counter bit, I guess...)
Some 'extensions' are magical and used in specific places. The 's'
extension is what seems to work to 'Start' a given extension context.
The 't' extension is used for Timeout handling after Dial and other
event-after-request dispatch.
Why won't changes I made in extensions.conf affect behavior of
system?
If you alter the extensions.conf file, the Asterisk server does not
seem to automatically read the file. You can issue a command to the
console of the Asterisk server to force the extensions in
extensions.conf (and others??) to reload. This command inside Asterisk
console is:
extensions reload
Does Asterisk support some kind of variable in the extension script?
see 'Asterisk variables' on wiki
Why did Asterisk hang up?
see HANGUPCAUSE variable on wiki
How do I get some info on what happened to a dial attempt?
see DIALSTATUS variable on wiki
I don't know enough about this, or Asterisk could use better support
in the call-status-monitoring department....in fact, DIALSTATUS variable
is in a fairly recent CVS HEAD so you have to be recent to get the
feature....
How do I execute an arbitrary command from extension context script?
see 'System command' on wiki
How do I "dial" an extension (or otherwise initiate a connection)?
see 'Dial' command on wiki
How do I Read DTMF data from the current call?
see 'Read' command on wiki
How do I record audio data during a connection?
see 'Record' command on wiki
How do I unconditionally branch in extension script?
see 'Goto' on wiki
How do I conditionally branch in extension script logic?
see 'Gotoif' command on wiki
How can I dump some debug info somewhere while my extension code is
running?
see 'NoOp' cmd on wiki