Im writing a bot, which acts as an interface between a user and an already existing web service.
My challenge now is to match for example a skype or slack user with an already existing user of the web service.
For that i need to know:
What is a unique identifier for lets say a slack user?
Is it the property "address", which is a cryptic mix of letters or is it the property "id" which is also a cryptic mix of letters?
Over the last few days, none of those 2 properties did change so im not sure.
I'd appreciate your help.
Greetings
Related
I'm building my first Teams app which will have two primary functions:
Proactively send a message to the channel (the bot is installed into) when a specific event occurs on my backend.
Members of the channel reacts to the message via actions.
I finally have a pretty good idea of how to set this up (I think) - but one part I'm missing is that in order to identify the specific app installation as belonging to one of my customers, I need to be able to allow the installing user to supply extra information like e.g. an API-key so that I can associate the specific channel with my specific customer.
Is there any way of doing this with a bot app? I've found examples for creating a configuration page, but they all seem to be associated with tab apps?
I could of cource have the bot ask the user for the information - but maybe there's a "cleaner" way?
Any examples or tutorials would be greatly appreciated as I find it rather hard to get stuff working using Microsoft's own examples etc. :)
Thanks a lot!
When you receive any message from the user, either by typing to your bot, or even installing it into a channel, group chat, or personal context (where you get the conversationUpdate event), you are able to get specific details off of the activity object. If the user sends a message, for instance, then the text property on the activity object will have a value. Incidentally, this is the same activity you will use to get the conversation details you need for the Proactive message.
With regards your question, the activity class also includes a tenantId property, hanging off the conversation property. This is the unique Microsoft 365 Id for the tenant, which would be what I'd suggest to uniquely identify them for your API, or licensing, or similar.
I'm building a Skype bot using Microsoft's framework and I want to recognize the users.
can anyone give suggestions on how to do it? The users should be recognized in order to give them authorization for tasks the bot preforms so it must be something that never changes and can be stored on a database.
The only thing I saw was "ServiceUrl".
thanks!
You can get the unique user id like below:
var userId = Context.Activity.From.Id;
This will always give you the user ID of the channel they reside on. In your case it will be their Skype ID.
I have numerous guests in my channel.
I'd like my bot to mention these guests in a # mention, but bots don't seem to see channel guests. It find other full users fine, just none of the guests.
Is this an intentional limitation of Slack or does the bot require more permissions?
I'm using the slackclient module (Python) and making the following call:
sc.client.api_call(
"chat.postMessage",
channel="#channel",
link_names=1,
text="#aaron.layfield <-- Working #guest.name <-- Not working This is a message."
)
If you want to link to users from inside of your message, the best format to use is <#USERID> instead of #username. This is because Slack has moved away from using usernames, and towards a more flexible concept of display names, which aren't guaranteed to be unique or immutable.
So in this case, you would do something like
curl --request 'POST' 'https://slack.com/api/chat.postMessage?token=xoxb-21321321-1231321321321-dsfasdgdsfaghsdfhsdfh&channel=C9UFK5F5S&text=Hey <#UFBKH3B63>'
Which would render as
Hey #Colm Doyle
As already explained by Colm's answer the #username syntax is depreciated and you should use the ID syntax instead for mentions.
To get the IDs for your guest users call users.list to get a list of all users in your workspace. Then iterate through that list to match guest name with ID.
I have a backend service where users can create and name rooms and devices. I'd like to integrate with Cortana and allow users to interact with their devices using Cortana. I created a bot that is hosted on my backend and added Cortana as a channel. I also integrated the bot with my OAuth 2 server so I know which user is interacting with the bot.
I trained my LUIS model with phrases like "turn on light in the bathroom", "turn off all lights", etc.
My issue: each user can name rooms and devices as they want. I do not know in advance which rooms and which devices are going to be configured in the service. When I get the request in my bot, I can find all devices for the user. The list is fixed at that point and could be used as a phrase list - only devices in the list are allowed to be in the request.
Which brings me to my question: is it possible to modify the phrase list on per-user basis? Or configure a URL from which the most recent phrase list could be retrieved before the request is processed by LUIS? Basically all I need is to avoid getting a request to turn on light in the "living room" while there is no living room configured by the user in the system and instead it should have been "dining room" (this is just a simple example, in the real world it would be more complex).
I know there is LUIS REST API that can be used to dynamically modify the configuration, but:
1) it is not on per-user basis
2) it requires re-building and re-publishing the LUIS model
I believe the Connected Home skills solve that somehow by discovering all devices connected to the service, but I haven't found any APIs I could use to solve the issue in my skill.
Edit:
I am looking for a functionality like this:
Cortana Connected Home
After linking the Hue account Cortana knows which devices the user has and at that point the voice recognition can be smart and try to map the spoken words to an actual device name.
Firstly, the phrase list feature can help LUIS recognize intents and entities, it will affect on that whole LUIS app. As far as I know, there are not concept of per-user basis phrase list feature in LUIS.
Secondly, LUIS app support 5,000 items per phrase list, if the number of your app system rooms (or devices) name does not exceed the limit, you can add all rooms’ name in a phrase list (and add all devices’ name in another phrase list).
Besides, you can also try this approach: when users can create and name rooms and devices, you can map information about user with rooms&devices and store the map information in a external store, such as a database etc. And if you pass query to LUIS, LUIS would help detect the intent and the entity(or entities or empty entities list), if there are not any entity in entities list, you can query records of rooms’ name from that external store and prompt the user for selecting a room.
Code snippet:
//query records of rooms’ name from that external store
//then prompt user for select a room
PromptDialog.Choice(
context: context,
resume: ChoiceReceivedAsync,
options: options,
prompt: "Hi. Please Select the Room :",
retry: "Please try again.",
promptStyle: PromptStyle.Auto
);
Test result:
From what I see, Bot Framework is providing an abstraction over users in different channels by providing a ChannelAccount class that has ChannelId/Address pair to identify user via its account and Id property, which is... okay, here's the question.
I suppose that the idea behind Id is to provide a unique and persistent identifier that can be used to cross-correlate users between account (i.e., I can say that Slack user #alpha is also email user alpha#company.con). This idea is supported by the fact that ChannelAccount for my bot always has same Id regardless of the channel (and Address is different between channels, obviously).
If this is right, and I hope it is, is there any way to provide BotConnector with the correlation information? I.e., I want BotConnector to give me ChannelId/Address, and I'd give back user Id which I'd the get back in incoming message.
The purpose of this is quite simple: I want the code inside my bot to use the Id as already correlated identifier so that I can log it, build logic from it and so on.
BotFramework does not yet support linking of accounts. In the interim, take a look at this post for one way you might implement a solution:
Why isn't BotUserData persisting and retrievable in my Bot Framework bot?