Microsoft Teams - invoke HTTP request on message/reply in team channel - microsoft-graph-api

In MS Teams whenever someone replies to a message in a particular team channel, I want to invoke a HTTP request or publish a message to something like Azure Service Bus.
Is there a way to do this?
FWIW I'm trying to do 2-way SMS between a users mobile device and an agent using MS Teams. I'm using Azure Logic App(s) as the glue between the SMS provider and MS Teams, but the 1 part of the communication loop that I don't know how to handle is when the agent replies to messages in MS Teams. I know I can get messages via MS Graph API, but I don't really like this polling approach - I'd prefer more of an event based approach.

Bartsch, currently we don't have any such event to trigger whenever someone replies to a message in a particular team channel. But have an option when a new channel message is added. As this feature is not available at present, could you please raise an User Voice if this needs to be consider as a future request.

Related

Listen to MS Teams Chat New Message

I'm trying to build a chatbot system which can interact with our organization's Microsoft Teams channel. The Chatbot will be deployed on GCP VM. I was wondering how to listen to new messages from Microsoft Teams so that the chatbot can reply Teams user correspondingly in real time.
I know we can use Graph API to get messages from Teams but it doesn't seem realistic to send API request every second to get messages from all Teams users. Is there any other approach?
(We cannot use Azure Bot Service in our organization)
You can Subscribe to chat message and once the message is sent, it will automatically notify to the configured endpoint.
Reference doc: https://learn.microsoft.com/en-us/graph/api/subscription-post-subscriptions?view=graph-rest-1.0&tabs=http

Is there a way to use a bot, webhook, or some other connector to be notified when someone joins an online Teams Meeting?

Our company uses Teams Online Meetings extensively. Teams is a great product and is a wonderful communication tool. We have a scenario where we need to be notified when a participant joins a Teams meeting, leaves the meeting, or the meeting ends (all participants have left).
Can a bot, webhook, or connector be setup to listen to those events? Also, these meetings will be dynamically created real-time (not a scheduled event) using the Microsoft Graph API. Can the bot, webhook or connector be programmatically added to the meeting in order to receive the join, leave and end meeting events?
Thanks for your help,
Joe
Yes and No...
The problem is that you can think of a "bot" as a virtual teams client for a bot user. So it has the same limitations as a "normal" client (in most cases). So unless you invite the bot into the call or the bot is already in the call (e.g. started the call) then no you can't do what you want. If the bot IS in the call already then yes you can do what you want. The bot can invite, drop participants and end calls.
There is another way, you can create a Policy Recording Bot and will automatically insert itself into every call for a user that has the policy set to them. There is a overhead that the call start up time is a lot greater and all such calls are now conference calls. So the media is NOT endpoint to endpoint any longer. See the sample for an example of this type of bot.
The other downside would be that Microsoft may not like what you are doing using the Policy Recording Bot for non-recording purposes.

Twilio SMS and Survey

I am using Twilio to communicate with my users via SMS. I have my own web application that reads the incoming Twilio message. I use a web hook for that purpose. I am able to read the incoming message and process it in my web application.
I would like to send out survey questions periodically during the day to the same number. I researched the Studio flow for this purpose. It looks like a good option to write a survey.
I have a doubt though. In twilio console I added my url as a web hook to receive all sms messages. If I build a studio flow then how do I use that. I already have a web hook but I also want to do a survey using the same twilio phone number. Is there a way to do this in Twilio.
What I want to achieve is I receive SMS from a twilio number all through the day using a web hook. Every 2 hours or so I would like to send out a survey question to the same twilio number and process the answer in my end. What is the best approach to do this? I use c# and .net core to write my web app.
Thank you
you can do this.
You would use the REST API path of the Studio Trigger widget of your Studio Flow, to kick off this outbound SMS. You can find more details below. The scheduling logic, every 2 hours, would be handled by your application logic.
Trigger a Twilio Studio Flow Execution via the REST API
Execution
We use the REST API trigger for the Appointment Reminder Studio example.

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)

What OAuth Scopes are required for a listen & reply Slack Bot using the Slack Events API?

I am trying to make a bot that will listen to all public & private channels, and IMs for a team, and will reply when it sees certain trigger words. This will be a "Slack App", installable to your team using the "Add to Slack" button, and includes a "Bot User".
I have asked for the "bot" OAuth scope, and subscribed to the "message.channels,message.groups and message.im" Team Events (at https://api.slack.com/apps/myAppId/event-subscriptions) but do not appear to receive event POSTs through the Events API when new messages are sent.
Adding the "channels:history,groups:history,im:history" scopes makes the bot receive these event POSTs, but I believe only for the user that added the bot, so it will not watch groups that the adding-user was not a member of, or IMs between 2 other users. This means that behaviour will be different, depending on which user installed my bot.
Is there a way of installing the app/bot for an entire team? The documentation seems to indicate that a 'bot' scope should have the ability to receive events, but I am not seeing this (I require the channels:history scope etc. above).
bot - request this scope when your Slack app includes bot user functionality. Unlike incoming-webhook and commands, the bot scope grants your bot user access to a subset of Web API methods, the RTM API, and certain event types in the Events API.
(from https://api.slack.com/docs/oauth-scopes)
The page on bots also claims that a bot can receive all messages through the RTM API:
This websocket will send you all of the messages and activity that happen in public and private channels that the bot user is invited to, as well as messages that are sent to it via direct message. A bot user opens this websocket with the RTM API by sending an authenticated call to the rtm.start API method. To learn more about connecting to the RTM API, read the documentation here.
(from https://api.slack.com/bot-users)
Is this same behaviour possible in the events API without needing to use the RTM API or add those additional scopes mentioned above?
I see from your comment that you have understood that the bot scope (and the channels.message Events subscription) allows your bot to receive from channels it is present in.
You have two options
1) you ask for channel.write scope in addition to bot, and you invite the bot in all channels (using the user token, not the bot token)
2) you work on your onboarding and figure out a way to get your "champion", ie the user who installed your app, to invite your bot in relevant channel.
Keep in mind that solution 1) is usually seen as very intrusive, especially in large teams where most people haven't heard of your app nor taken the decision to install it. But it can be suitable for some very specific use cases. Option 2) is the recommended route, but it is hard :-) Good luck!

Resources