How to send messages (3 types, text only) from external service to MS Teams user; each type can be toggled ON or OFF by that user in MS Teams? - botframework

Im new to MS Teams application development and looking for suitable solution based on the following requirements. Can I have some guidance from experts?
I have a web service, which sends emails to users based on certain activity. Eg: "Survey started", "Reminder for those who didn't complete the survey" and "when the survey results are out". On top of the email notifications, I also want to send a notification to those individuals who opt-in to receive the notification in MS Teams.
My requirements are,
My web service should be able to send the notification to those
opt-in users in MS Teams as a private message and not as a message in
groups/channels.
In MS Teams, the users should have control over which notification
they wants to receive. For eg: "User A" can opt-in to receive a
notification when a survey starts & survey reminders but can opt-out
of survey results notification where as "User B" can opt-in to
receive notifications for all three.
opt-in and opt-out settings for specific notification should be
configurable in the MS Teams. My web service irrespective of the
settings, will always send the notification to MS Teams but it will
be controlled in the MS Teams side whether to show the notification
to the user or not based on the individual user settings.
Based on the above requirements, please advise what should I build in MS Teams. Whether "Tabs" is enough or "Bot" needs to be built or anything else.
Any guidance or suggestions are really appreciated. Thanks in advance.

Please find below suggestions as per your requirements:
You can use the activity feed notification APIs in Microsoft Graph
to extend this functionality or SDK methods:
Reference doc link, Reference sample link
Also you can send proactive notifications via bot to user:
Send proactive messages
You can create a configurable page and add it to your Tab, which
will be visible to all users who install the bot.
There is no way in MS Teams which will filter or control the
notification to send it to different users without any custom
configuration or condition check.

Related

Send a user message to a user via Power Automate in MS Teams

Is there a possibility to send a user message to specified user(s) in MS Teams?
Elaboration:
My current flow triggers a message to a user, but it is always sent via FlowBot and appears in the Power Automate chat of MS Teams.
Flow: (Outlook; Trigger) "When a new email arrives (V3)" → (MS Teams) "Post message in chat or channel" → (Outlook) "Mark as read or unread" (v3)
Can individual users be set as recipients of direct messages with the message sent in the already existing chat with the user?
If yes, is it possible without a value chain?
Thanks!
As I see it, there are kind of a few different questions in your post, so I'll try deal with each of them:
In order to send a message directly to a user, the user has to come "from" someone/something, and in Teams that basically means a Bot. The easiest way, therefore, to do this is to use the out-of-box FlowBot. If that's fine for you, you're good to go. If you want it to come from another Bot (i.e. one you own) then you need to create a Bot somehow. Two main options are:
Code it from scratch using Microsoft Bot Framework - code in a regular language (C#, Python, etc.) or using Bot Framework Composer
Use Power Virtual Agents - ala "Power" family, it's kind of a "Drag and Drop" bot capability. You don't need to actually have the bot DO anything though, if you don't want it to handle user responses (you can do most of that visually in your Power Automate flow. For this option, you'll be able to select the bot from within Power Automate designer as the "send from" bot
You can choose to have the bot send a message directly to the user (i.e. in a 1-1 chat, like what you're seeing with FlowBot) or you can choose to have it send to a particular Channel inside Teams - either is fine. Be aware that Channels have threaded conversations, if you want to use them, but 1-1 chats do not.
You can try these Power Automate steps to create the 1:1 chat between you and the user, then send a message to it.

Time out, Image send, Email track adding to bot framework composer

I have developed a chatbot for IT Support team in our company, running on MS Teams using Bot Framework Composer. I have integrated it with Azure logic apps to send emails to IT Support team.
I want to know how to;
Get user's email address in MS Teams (We can get user's name using ${turn.activity.from.name} telemetry track event)
Set a timeout period
Send a Image to using HTTP request in JSON format (Then users can upload the screenshot of their issue)
Yes, you can get the user's email address in MS teams by making fetching the roster or user profile or make use of get single member detail from this documentation.
Not sure if you want to restart a conversation or track the last time a message was received from a user, but you can refer to Expire a conversation documentation to get started with.
MS Teams makes use of webhooks to integrate with external apps and makes use of Standard HTTP message exchange feature where responses appear in the same chain as the original request message and can include any bot framework message content, for example, rich text, images, cards, and emojis.

How to send message to all the members of the group on Installing teams bot

I have created a teams bot and had a service written in .NET core to handle events and user's messages to reply accordingly.
When I install a bot in a group, I need to send personal message(one-to-one i.e between bot and the user) to all the members of that group on installation. I am trying to do that in OnConversationUpdateActivityAsync event handler (which gets fired when I install the bot). But in this event I am getting information of the user who is installing the bot, not the other members which are added in that group, also I am not getting any information of the channel(channelId and members etc.) in which the bot is getting installed.
Any different approach or solution will work.
Thanks in Advance.
You haven't said if you want the bot to message the users privately (like 1-1 between the bot and user) or just send each person a personal message inside the group chat, but in both cases, Proactive Messaging is your correct approach. If you want to send a message inside the group chat itself, see this sample.
If you want to send the users messages directly, 1-1, they need to have the bot installed as a personal app already. It's possible to do this automatically, but it's a bit more work, and requires Microsoft Graph. The proactive messaging is a bit different too - you get the list of members as per the previous sample, but see here for how to get the required 1-1 conversation details, and how to send the actual message. This last link also has documentation on how to get started, and some background reading (at the bottom of the page).
#Hilton is correct, You need to specify in which scope you want to notify user 1:1 or directly in Group chat?
App should be installed in user scope if notifying user on installation, You can proactively install the App in User/Group Chat/ team scope using Graph API. To notify users in Teams or Group chat, You can fetch the list of members using List conversation members API, When you install the App using Graph API Bot received converstionUpdate, You can save the conversationReference and use it for proactively notifying.

How to make a bot to message only certain people

I developed a welcome bot using the Microsoft Bot Framework. I want to add it to Teams. In teams I want the bot to send welcome messages to only certain members belonging to a particular team or group. Please provide me advice or steps how to do it.
You can only send a welcome message to a specific user if that user first contacted your bot. This is done purposefully to minimize the possibility of spam bots being created. Once a user has contacted your bot you can capture the user's Id and, coupled with the conversationId, you can send future (proactive) messages.

Sending context information to chatbot

While launching a web chat bot from a portal (through iframe), is it possible to send the details of the logged in user (who has already logged into the portal) to the bot and save it in the bot state so it can retrieved inside the bot code to do some customization or apply custom logic based on the user details. User details can include their name, date of birth, gender etc.
Your web app and bot can exchange information "behind the scenes" (i.e., invisible to the end-user) by exchanging activities of type event. An activity with type event will not be displayed by clients such as Web Chat, so the end user won't see any evidence of the communication. This type of communication between client and bot is sometimes referred to as the "backchannel mechanism."
For an example of how this is done, check out Ryan Volum's backchannel sample bot.

Resources