Section | ||
---|---|---|
|
...
|
...
|
...
|
...
|
Asterisk offers the following presence states:
not_set
: No presence state has been set for this entity.unavailable
: This entity is present but currently not available for communications.available
: This entity is available for communication.away
: This entity is not present and is unable to communicate.xa
: This entity is not present and is not expected to return for a while.chat
: This entity is available to communicate but would rather use instant messaging than speak.dnd
: This entity does not wish to be disturbed.
In addition to the basic presence states provided, presence also has the concept of a subtype and a message. The subtype is a brief method of describing the nature of the state. For instance, a subtype for the away
status might be "at home". The message is a longer explanation of the current presence state. Using the same away
example from before, the message may be "Sick with the flu. Out until the 18th".
Like with device state, presence state can be placed in hints. Presence state hints come after device state hints and are separated by a comma (,
). As an example:
No Format |
---|
[default]
exten => 2000,hint,SIP/2000,CustomPresence:2000
exten => 2000,1,Dial(SIP/2000)
same => n,Hangup()
|
This would allow for someone subscribing to the extension state of [email protected]
to be notified of device state changes for device SIP/2000
as well as presence state changes for device CustomPresence:2000
. The CustomPresence
presence state provider will be discussed further on this page.
Also like with device state, there is an Asterisk Manager Interface command for querying presence state. Documentation for the AMI PresenceState
command can be found here.
|
Presence States
not_set
: No presence state has been set for this entity.unavailable
: This entity is present but currently not available for communications.available
: This entity is available for communication.away
: This entity is not present and is unable to communicate.xa
: This entity is not present and is not expected to return for a while.chat
: This entity is available to communicate but would rather use instant messaging than speak.dnd
: This entity does not wish to be disturbed.
Subtype and Message
In addition to the basic presence states provided, presence also has the concept of a subtype and a message.
The subtype is a brief method of describing the nature of the state. For instance, a subtype for the away
status might be "at home".
The message is a longer explanation of the current presence state. Using the same away
example from before, the message may be "Sick with the flu. Out until the 18th".
func_presencestate
And The CustomPresence
Provider
...
CustomPresence
is device-agnostic and can be a handy way to set and query presence. A simple use case for CustomPresence
is demonstrated below.
Note |
---|
The following dialplan is meant strictly for demonstration. It is not intended to be used as-is in a production environment. |
No Format |
---|
[default] exten => 2000,1,Answer() same => n,Set(CURRENT_PRESENCE=${PRESENCE_STATE(CustomPresence:Bob,value)}) same => n,GotoIf($[${CURRENT_PRESENCE}=available]?set_unavailable:set_available) same => n(set_available),Set(PRESENCE_STATE(CustomPresence:Bob)=available,,) same => n,Goto(finished) same => n(set_unavailable),Set(PRESENCE_STATE(CustomPresence:Bob)=unavailable,,) same => n(finished),Playback(queue-thankyou) same => n,Hangup exten => 2001,1,GotoIf($[${PRESENCE_STATE(CustomPresence:Bob,value)}!=available]?voicemail) same => n,Dial(SIP/Bob) same => n(voicemail)VoiceMail([email protected]) |
...
Note |
---|
One thing to keep in mind with the |
Configuring Presence Subscription with Hints
Like with device state, presence state is associated to a dialplan extension with a hint. Presence state hints come after device state in the hint extension and are separated by a comma (,
). As an example:
No Format |
---|
[default]
exten => 2000,hint,SIP/2000,CustomPresence:2000
exten => 2000,1,Dial(SIP/2000)
same => n,Hangup()
|
Warning |
---|
The hint definition must contain both a device and presence state provider for presence state notifications to be generated. You cannot define a hint referencing a presence state provider by itself. |
The above example would allow for someone subscribing to the extension state of [email protected]
to be notified of device state changes for device SIP/2000
as well as presence state changes for the presence provider CustomPresence:2000
. The CustomPresence
presence state provider will be discussed further on this page.
Also like with device state, there is an Asterisk Manager Interface command for querying presence state. Documentation for the AMI PresenceState
command can be found here.
Example Presence Notification
When a SIP device is subscribed to a hint you have configured in Asterisk and that hint references a presence state, then upon change of that state Asterisk will generate a notification. That notification will take the form of a SIP NOTIFY including XML. In the expanding panel below I've included an example of a presence notification sent to a Jitsi softphone. This particular presence notification happened when we changed presence state for CustomPresence:6002 via the CLI command 'presencestate change'.
Expand | ||
---|---|---|
| ||
|
Digium Phone Support
Digium phones have built-in support for Asterisk's presence state. This Video provides more insight on how presence can be set and viewed on Digium phones.
...