how to send a message with a attachment to Teams through Graph API? - microsoft-graph-api

Microsoft has provided updated API for sending messages to channel in Teams.
Post Message in Teams
after this update, now we can give importance, mention the user in sending a message to Teams.
curious to know, can we send messages with attachment in this new update?
have a look on below link for the chatMessageAttchment resource type that is used for sending a message with an attachment.
chatMessageAttchment
I want to know what all we can be achieve in this new endpoint.
POST https://graph.microsoft.com/beta/teams/{id}/channels/{id}/messages

This is not currently supported, I'll add a note to the docs clarifying this.

Related

Slack API: Can I get all unread messages for a user?

I develop a mobile app Speaking Email that reads emails out to the user, which can be used while driving to work for example. I would like to add Slack as an account type. Ideally we would have Speaking Email read out the user’s slack messages that are unread, as these will be what they need to catch up on. However it does not appear the Slack API has a method for retrieving the messages the user hasn’t read. Is this possible with the latest Slack API?
I was searching for the same thing and found their API doc about Read Messages!
https://api.slack.com/messaging/retrieving

Posting to a teams channel from a logic app or flow which includes an banner alert / activity feed item

I have a logic app which posts a channel chat message to teams automatically when a new item is created in SharePoint. This I have working but our client requires that all the team members receive a banner alert and activity feed which I am having a lot of difficulty with.
What I've already tried...
Using a Incoming web hook on the teams channel - this was a very simple way to post from the logic app but the incoming webhook don't seem to support mentions.
Using the msft graph api - The /team/channel/message endpoint can post messages and user mentions but the this endpoint doesnt support channel or team mentions. It also appears that the graph API needs to use delegated permissions to post messages in teams. I'm using application permissions as this is a logic app. The logic app HTTP post connector doesnt offer the "connect as username#tenant.com" some of the other connectors use.
Using the flowbot post message - Like the above channel and team mentions are supported here so the post is added to the channel but with no notification to the team members
Using a notification only bot - I thought I nearly had it with this one. Microsoft's node bot sample number 57 looked like it can do most of what I want, it iterates through the users in the team and messages them this a customisable alert message...
https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/57.teams-conversation-bot
However I can't see how this bot can be triggered from my logic app as it seems to require an existing conversation context or an #mention from within teams to start communicating with users.
What I'm considering trying next
Iterating users within the logic app - Next I plan to try and get team membership from the graph API and iterate the members in the Logic App, posting a message to each user separately. I had hoped to utilise the group #mention feature as a simpler way so I'd be grateful if anyone had any thoughts on other ways of doing this, or maybe there's something wrong with what I've already tried that you could give me some expertise on.
Thanks in advance ;)
Andy
You're on the right track with the Bot, but you're wanting to send something called a "Pro-active" message. You need the bot registered in the channel in order to get access to a few key properties (conversation id, service url, etc.), but you can use those to send a message from -outside- your bot (e.g. in an Azure Function). You might be able to do this directly from a Logic App, but I haven't tested that specifically.
To find out more, see my answer at Programmatically sending a message to a bot in Microsoft Teams but I've also got a recent blog post that you might find interesting for background on this at How Bots Actually Work.
Hope that helps
You can use Graph to post a message in 1:1 chat as long as you have the chat it. You can find the answer in this post Send message to personal Chat via Graph API
You can also call Graph API from Logic Apps. (https://techcommunity.microsoft.com/t5/integrations-on-azure-blog/calling-graph-api-from-azure-logic-apps-using-delegated/ba-p/1997666#:~:text=Calling%20Graph%20API%20from%20Azure%20Logic%20Apps%20using,Manage%20-%3E%20Certificates%20%26%20secrets%20More%20items...%20)

Send message to personal Chat via Graph API

I read from here that getting a user's Teams chats that occurred outside the scope of a team or channel (1-to-1 chat conversation), you need to use this request
GET /users/id/messages
and Teams chat messages have "IM" as their subject.
My question now is whether it is possible to send a new message to this conversation via the Graph API and that the message will be displayed on the Teams application?
I tried to reply to this message via the graph API, but the reply message was sent to Outlook, not in the Microsoft Teams application.
It is now possible to send messages to personal chat(1:1) or to group chat in Microsoft Teams using Microsoft Graph API. And yes, the messages will be displayed in the Teams application using Microsoft Graph API.
Please refer the "1:1 and group chat messages" section from the below microsoft documentation link:
chatMessage resource type
Also, below is the graph API to send a message to any conversation you want using Post HTTP method :
https://graph.microsoft.com/beta/users/{user-id}/chats/{chat-id}/messages
To fetch {user-id} and {chat-id}, please follow the below steps using Get HTTP method:
Fetch the user id of a logged-in user or user id of other user using below graph API's:
https://graph.microsoft.com/v1.0/me
https://graph.microsoft.com/v1.0/users
Fetch the conversation/chat id of a user:
https://graph.microsoft.com/beta/me/chats
https://graph.microsoft.com/beta/users/{id}/chats
As of now, there is no graph API to reply to a personal chat but we can reply to any team's channel message using Microsoft Graph API.
The answer, for now, is no. The docs have stated
"In both the v1 and beta endpoints, the response of GET /users/id/messages includes the user's Microsoft Teams chats that occurred outside the scope of a team or channel. These chat messages have "IM" as their subject."
You may submit/vote an feature request in the UserVoice or just wait the update from the Product Team.
Here is a detailed explanation to answers that #parvin provided if you are trying to do this using Graph Explorer. There is one difference that in this method you don't need to have user-id anymore and chat-id would suffice. Simply Post HTTP method:
https://graph.microsoft.com/v1.0/chats/{chat-id}/messages
if you don't know how to get the chat-id, pleaser refer to answer provided by Parvin. Make sure your message is in the json format and you can put that in request body.
Then you can go to "Request headers" tab and add "Content-type" as Key and "application/json" as value.

How to make your bot user reply with a simple help message using slack bot

I have created a slack bot and I want to send a general static help message to users when they send a direct message to my bot:
Should I subscribe to Events API? Or do I need to do this in another way? I couldn't find a clear answer for this.
There are two ways to do make your bot user reply to direct messages:
Events API
Real Time Messaging API
In my opinion the Events API approach is easier to implement since it does not require using WebSockets.
The basic approach with the Events API is:
You need an endpoint that can receive event requests from Slack and
react to it, e.g. by sending a direct message back to a user.
Subscribe to message.im event for your bot user
Note that a bot user already has all the required scopes for this with the bot scope.
In addition I would recommend to subscribe to app.mention for your bot user. Then it can also react to mentions in other channels.
Btw. that message you posted looks a lot like a review comment from the Slack team for a new app submission. I got a similar one for my last app and I solved it with the approach above. In general it looks like if you want to have a bot user in your app it needs to be able to respond to help request from users.

Can I send attachments to a Zendesk ticket via email?

According to the Zendesk documentation:
Receiving attachments from customers
Zendesk accepts attachments from users sent in via the API, email and web form channels in your Help Center.
However, I can't find any information in the documentation to accomplish this.
I'm not sure I fully understood the question, but you can just attach your document to the email you are sending in to update the ticket.

Resources