I have a bot application developed in java sdk. To integrate with MS Teams, I have a connector has been created using Bot Framework and Spring Boot and a Bot Channels Registration on the Azure portal. Everything working properly. Now I'm trying to implement proactive messages by following this tutorial: https://www.vrdmn.com/2020/02/microsoft-bot-framework-v4-send.html
I can already make the bot send proactive messages on channels, but now I need to implement the post a proactive personal message to a user.
I can get data from a user:
var user = await ((Conversations)connectorClient.Conversations).GetConversationMemberAsync(mentionUserPrincipalName, teamInternalId, default);
But when running the line...
var response = await connectorClient.Conversations.CreateConversationAsync(conversationParameters);
...a bad request result is returned with the message "Invalid user identity in provided tenant":
You can get the user details using teams roster. To create a new conversation or conversation thread in a channel, you must have the correct ID. You can receive or retrieve this ID. Please check Get the user ID, team ID or channel ID. You can also fetch the list the members of a team using teams roaster. Please check Fetch the roster or user profile.
Related
So the discord bot (Discord v12) I'm designing in nodejs has a command that must go through a DM (it's a silent auction bot so the bid messages being sent as bids can't be seen). Since I'm designing the bot to be able to be used on multiple servers I need a way to assign the server ID from the DM message so the bot knows the bid is for that particular server's auction. Since it's a DM I can't pull the server ID from the message itself.
The only way I've thought to accomplish this is by having the members logged into a voice channel of the server, but I can't figure out a way to pull the server ID from the voice channel itself. Is there a way to pull the voice channel ID a member ID is currently logged into and pull the server ID from that?
You can get information regarding a voice channel where the user is logged with the VoiceState object.
You can get it from a member's .voice attribute.
I'm building a Node only application that reads logs in the background and based on an event being read will send a message to a Teams channel directly.
I've been having quite a few issues getting a Graph API access token valid through Username and password.
I have been able to get a Graph API access token with client secret and tenant id which represents access
"without a user". Now that does not allow me to post a message in a channel as I would need to have access "on behalf of a user".
API => https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/messages .
Would there be another way of achieving this? Webhook/Connectors?
Thank you!
There's a few different ways you can post to a teams channel, you can set up like you said an http webhook, where you could call it to post into a channel https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using
You can use power automate (flow) or logic apps to post messages as the flowbot, or you can write a bot/ use the bot framework to register a bot that can post to teams, called proactive messaging: https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bot-conversations/bots-conv-proactive
As for trying to use graph with application permissions, that's not possible, at least for the moment.
I'm making a slack bot (A) that responses to a message from another slack bot (incoming-webhook) (B).
I'd like to know the user_id of B so that its message will be a trigger for A, where I have some problem getting it.
I tried users.list method (https://slack.com/api/users.list?token=blabla) but the B didn't appear in a result.
Do you have an idea about what method to take to know the user_id of B?
Incoming webhooks appear as apps, not as bot users on Slack. So you won't find a bot user ID in the user list as you would for normal bot users.
Apps have a bot ID, but unfortunately there is no official API method to get the list of bots / apps in a workspace. But if you have control over a workspace and can generate a legacy token you can use the unofficial API method bots.list.
There also is the official bots.info method, if you already have the bot ID and just want to know which app it belongs to.
To create a legacy token for your workspace make sure you are logged in and then go to this page.
I'm trying to list message in a channel in Teams using Graph Api, and I get a 401 (Unknown Error) response from the server.
Listing teams and listing channels in teams works. Getting the channel also works, but I can't get messages.
I'm using App ID (deamon scenario) and the nodejs graph api.
If anyone can point me in the right direction...
(edit, more info)
const client = GraphClient.initWithMiddleware({
defaultVersion: 'beta',
authProvider: new AuthProvider()
});
await client
.api(`/teams/${teamid}/channels/${channelid}/messages`)
.get();
and the app permissions:
(edit 2, decoded jwt token)
This is apparently not supported as in https://learn.microsoft.com/en-us/graph/teams-protected-apis.
Extract from the documentation:
Microsoft Teams APIs in Microsoft Graph that access sensitive data are considered protected APIs. These APIs require that you have additional validation, beyond permissions and consent, before you can use them.
The following APIs are currently protected:
List channel messages using application permissions
Get channel message using application permissions
List replies to a message using application permissions
Get a reply to a message using application permissions
List messages in a chat using application permissions
Get message in chat using application permissions
There is a manual process to ask those permission to Microsoft. See the documentation.
I am building a bot for messenger using Microsoft Bot Framework. I got the bot registered with messenger and have set up a basic echo bot.
I however want to access the user's email id to check for security. How do I access this from the framework. The user id in the session object gives me the page id but not the user id.
Any idea on how the user id can be retrieved?
Answering for someone looking at this now. The user id in the session object is actually the page scoped user id.
On the node.js SDK of Microsoft Bot Framework it can be accessed with
var user_id = session.user.id
This id along with the page access token can be used with the Facebook Graph API to get additional details. Using the requests module from npm
r = requests.get("https://graph.facebook.com/v2.6/"+ user_id + "?fields=first_name,last_name,profile_pic,email,locale,timezone,gender&access_token=" + page access token)
The return object contains the following data
First Name
Last Name
Email
Locale
Timezone
Gender
you can use channel data in the Activity To access all the original information That comes from the facebook (or all other channel) e.g:
Activity activity;
dynamic d = JObject.Parse(activity.ChannelData.ToString());
Documentation