Hi community,
in order to use AdaptiveChoice I trigger a notification with "run command ..." which will trigger another command via button after the user has made a selection.
Custom Command>Notification>Selection>Submit>Custom Command
This works because I know my own chat ID.
But how can I get the chat ID dynamically in the automation script, depending on which user called the command from Teams?
Hi Felix,
We added a new example "Executor Input Example" for custom commands on how you can know who executed it. You can deploy it from the catalog: Custom Command Examples | Catalog (dataminer.services).
I will be adding/documenting the example on github as well in the course of the day: ChatOps-Extensions/CustomCommandExamples at main · SkylineCommunications/ChatOps-Extensions (github.com)
You can already see how it's done if you deploy the example. Feel free to shoot any questions.
Wkr
Hi Jordy, thanks for the quick implementation. It works very well.
Br, Felix
Glad to hear!
Hi Felix,
When a custom command is triggered, the automation script is ran in the name of that user's linked DataMiner account, so you always know who clicked the button. You are able to fetch the private chat of a given user with the Chat Integration nuget.
Note that someone can also click the button in a channel if it was sent/ran from there, so you cannot know it up front. If you want to send something in the chat/channel where it was clicked (not only in private to the user who clicked it) you can do it with the output (engine.AddScriptOutput, also supports adaptive card output)
Br
Thank you Jordy.
Do you mean via chatIntegrationHelper.Teams.TryGetPrivateChat(email)?
How do I get the user’s e-mail address?
I only know engine.UserDisplayName/UserLoginName.
Yes, I would have expected that you can get the email value from the DataMiner account but it doesn’t seem to be possible in Automation right now.
I will check if I can provide the email address of the user who clicked the button as a parameter input on the automation script by default.
Hi, I can confirm I will be able to do it this way. I will continue the implementation next week and reply here when it goes live so you will be able to use it as well. The DataMiner bot will basically check if the custom command requests the ‘dataminer.services User Email’ as parameter input, and if so, the DataMiner bot will not request that input from the user but provide the custom command the email address of the authenticated user clicking the button.
For this specific case I found a solution by replaceing chatIntegrationHelper.Teams.TrySendChatNotification whith engine.AddScriptOutput. But it would be nice to know if it is possible in general.