Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: More fleshing out of the whole page.

...

Extension state is the state of an Asterisk extension, as opposed to the direct state of a device or a user. It is the aggregate of Device state from devices mapped to the extension through a hint directive. See the States and Presence section for a diagram showing the relationship of all the various states.

...

When Asterisk loads the configuration file it will create hints in memory for each hint defined in the dialplan. Those hints can then be queried or manipulated by functions and CLI commands. The state of each hint will regularly be updated based on state changes for any devices mapped to a hint.

The full syntax for a hint is

No Format
exten = <extension>,hint,<device state id>[& <more dev state id],<presence state id>

Here is what you might see for a few configured hints.

No Format
[internal]

exten = 6001,hint,SIP/Alice&SIP/Alice-mobile
exten = 6002,hint,SIP/Bob
exten = 6003,hint,SIP/Charlie&DAHDI/3
exten = 6004,hint,SIP/Diane,CustomPresence:Diane
exten = 6005,hint,,CustomPresence:Ellen

Things of note:

  • You may notice that the syntax for a hint is similar to a regular extension, except you use the hint keyword in place of the priority. Remember these special hint directives are used at load-time and not during run-time, so there is no need for a priority.

After the hint keyword, you use a comma and then provide a list of ampersand delimited devices.

  • Multiple devices can be mapped to an extension by providing an ampersand delimited list. 
  • A presence state ID is set after the device state IDs. If set with only a presence state provider you must be sure to include a blank field after the hint as in the example for extension 6005.
  • Hints can be anywhere in the dialplan. Though, remember that dialplan referencing the extension and devices subscribing to it will need use the extension number/name and context. The hints shown above would be 6001@internal, 6002@internal, etc, just like regular extensions.

Querying Extension State

Once you have defined some hints, you can easily check from the CLI to verify they get loaded correctly.

No Format
*CLI> core show hints
    -= Registered Asterisk Dial Plan Hints =-
                   6003@internal            : SIP/Charlie&DAHDI/3   State:Unavailable     Watchers  0
                   6002@internal            : SIP/Bob               State:Unavailable     Watchers  0
                   6001@internal            : SIP/Alice&SIP/Alice-  State:Unavailable     Watchers  0
                   6005@internal            : ,CustomPresence:Elle  State:Unavailable     Watchers  0
                   6004@internal            : SIP/Diane,CustomPres  State:Unavailable     Watchers  0
----------------
- 5 hints registered

In this example I was lazy, so they don't have real providers mapped otherwise you would see various states represented.

See the Querying and Manipulating State section for more about accessing the state from dialplan or Asterisk applications.

SIP Subscription to Asterisk hints

Under Construction!