November 13, 2020

Teams Shortcuts: Send Mentions

In this post I highlight a feature implemented in the TeamsShortcuts PowerTool.
This is about automagically type Microsoft Teams mentions from emails copied to your clipboard. 
This also provide the option to personalize them (i.e. reformat to first names only)

Usage

Copy something in your clipboard that contains users' email addresses.
Example it can be a list of users in an Outlook meeting or Email but also some Html page containing a list of users.

The tool will parse the clipboard content to extract the emails.

In Teams, you can access the Teams Shortcuts function either via Win+T and select in the menu Send Mentions or using the Hotkey Alt+Q (Q is where the @ symbol is on my clipboard)

Setting to Personalize Mentions

In the Settings accessible from the Teams Shortcuts System Tray icon context menu (right-mouse-click on the icon), you can set if the Mentions shall be shortened to the Firstname.


There is an option in the Teams Shortcuts Settings to activate mention personalization.
If it is active, mentions will be shortened to the Firstname.

Screencast

TODO

Implementation notes

Pasting mention in rich text format (like it is done for HCL Connections) does not work in Teams.
To get a mention one need to simulate the keystroke typing. 
This is done with SendInput in AutoHotkey and using {Tab} to autocomplete.
The timing is quite important. If you type too fast Teams does not have the time to properly autocomplete the mention. (Look at the Sleep commands below)

The core function that types one Mention looks like this (implemented in ahk/Lib/Teams.ahk/Teams_SendMention function):

Teams_SendMention(sInputdoPerso := ""){
; See notes https://tdalon.blogspot.com/teams-shortcuts-send-mention
If (doPerso = "")
    doPerso := PowerTools_RegRead("TeamsMentionPersonalize")

If InStr(sInput,"@") { ; Email
    sName := People_ADGetUserField("mail=" . sInput, "DisplayName")
    sInput := RegExReplace(sName, "\s\(.*\)") ; remove (uid) else mention completion does not work 
} Else If InStr(sInput,",") {
    sName := sInput
    sInput := RegExReplace(sName, "\s\(.*\)") 
} 
SendInput {@}
Sleep 300
SendInput %sInput%
Sleep 1000 ; time for autocompletion
SendInput +{Tab} ; use Shift+Tab because Tab will switch focus to next UI element in case no mention autocompletion can be done (e.g. name not member of Team)

; Personalize mention -> Firstname
If  (doPerso=True) {
    Teams_PersonalizeMention()
}
} ; eofun

The implementation relies on ActiveDirectory access to convert emails to names that will be autocompleted.
I use the DisplayName AD Property. I have noticed that the autocompletion does not work if you send the name including (uidxxx) - so I remove this part before sending.

For the mention autocompletion I use the Shift+Tab combination to handle the case if the mention can not be autocomplete (no match e.g. user is not a member) without losing focus of the compose box (which happens in this case with the normal {Tab} key).

See also

Teams shortcuts: personalize mentions

No comments:

Post a Comment