Do you remember the "Alert When Available" feature in the (old) Cisco Jabber chat menu? If not, here is a quick recap. The "Alert When Available" option configured Cisco Jabber to notify you when your contacts are available (i.e., online/active). This makes it easier to know if other people are available to respond to your messages.

For some reason, this option is missing from the Webex chat menu . So, without getting into a Jabber vs. Webex discussion, I wondered how I can enhance the Webex user experience and add that missing functionality?

What can we do.. Let's think…

  1. Does Webex expose its API?… YES!
  2. Is there an API call to check the user connection status?… YES!
  3. Can I use a CLI command to trigger an API call?… YES!

Interesting! But…

  • How can I add a new option to the Webex chat menu?
  • What about the Webex API tokens limitation?
    • The personal access token is limited to 12 hours.
    • The guest user token cannot access the "status" data as it isn't part of the organization.
    • The integration token (OAuth grant using a web browser) isn't applicable for a simple script.

I got it!

  1. True, I cannot modify the Webex chat menu… but, can AppleScript execute a CLI (cURL) command?… YES!
  2. Since a WebEx Bot is part of the organization, can I create a new Bot and use its (permanent) API token?… YES!

Problem Solved!

So… I created a:

  1. cURL command & parsing statement to get the user status.
  2. New Webex Bot (for an "inside-org-permanent" API token).
  3. AppleScript to:
    1. Query (via dialog box) for the user CEC ID.
    2. Set a five seconds loop for the cURL command.
    3. Display a dialog box to notify when the user becomes active.

The Code (Mac OS only)

1setuserName to text returned of (display dialog "Enter a CEC User Name (e.g., ymeloch)"defaultanswer ""with title "Webex - Active User Notification"with icon file "Applications:Webex.app:Contents:Resources:webexteams.icns")
2settheAlertText to "WebbEx Teams - Active User Notification"3settheAlertMessage to "" & userName & " User is now active"4  ​
5setn to 16  repeat
7     delay 58settheName to doshell script "curl -s --request GET --url 'https://api.ciscospark.com/v1/people?email="& userName & "%40cisco.com' --header 'Authorization: Bearer [webex-bot-token]' | json_pp | grep status | awk '{print $3}' | tr -dc '[:alnum:]'"9iftheName = "active"then (display dialog theAlertMessage with title "Webex - Active User Notification"with icon file "Applications:Webex.app:Contents:Resources:webexteams.icns"buttons {"Exit"} defaultbutton "Exit"cancel button "Exit")
10endrepeat

The Code Explained


curl -s --request GET --url 'https://api.ciscospark.com/v1/people?email=" & userName & "%40cisco.com' --header 'Authorization: Bearer [webex-bot-token]' | json_pp | grep status | awk '{print $3}' | tr -dc '[:alnum:]'

Note: To add the Webex icon to the AppleScript dialog, I extracted the webex.app file, and located the ​​​​​​​"webexteams.icns" file.

Demo

Disclaimers

Final thoughts

Special thanks to Paul Giralt for his review and feedback!

Related developer resources

We'd love to hear what you think. Ask a question or leave a comment below.
And stay connected with Cisco DevNet on social!

Twitter @CiscoDevNet | Facebook | LinkedIn

Visit the new Developer Video Channel

Share:


Attachments

  • Original Link
  • Original Document
  • Permalink

Disclaimer

Cisco Systems Inc. published this content on 08 December 2021 and is solely responsible for the information contained therein. Distributed by Public, unedited and unaltered, on 08 December 2021 21:51:06 UTC.