0

I am trying to build a bot that can initiate a message direclty to a user who is in our organization (i.e. not a message into a Teams channel). I was only able to do this with the following methods:

  1. when the user initiates the conversation?
  2. when the user install the apps from the app store (the bot app is available)
  3. when the user is added to the teams channel where the app is installed.

I have spent a huge amount of time searching the solution documentation and now I'm getting the feeling that my requirement is not possible. It would be really nice if someone has some leads on it?

Thanks in advance

Hilton Giesenow
  • 9,809
  • 2
  • 10
  • 24
  • Please provide enough code so others can better understand or reproduce the problem. – Community Mar 21 '22 at 18:13
  • 1
    I'm having quite an active chat on another thread on this topic - please see here for info: https://stackoverflow.com/questions/71547766/sending-proactive-messages-from-an-outside-process-to-organizational-users-via-t/71550069?noredirect=1#comment126477032_71550069 – Hilton Giesenow Mar 21 '22 at 19:22
  • Thanks, @HiltonGiesenow. In the above thread, the bot is only able to continue conversation right? either the user is added to a team channel where the bot app is installed or the user installs the bo in the personal context. In both scenarios, we save the conversation reference we get from the conversation update activity and can be used for future proactive 1-1 messages. In my scenario, I cannot have the above two options. The bot app is only available in the organization's app store. Is there any way that the bot can initiate a conversation with a user using his email id or something else? – zack_dilan Mar 22 '22 at 10:07
  • ok got you. See proper answer below. – Hilton Giesenow Mar 22 '22 at 10:55

2 Answers2

1

Per the conversation above in the original post, Bots in Teams can only continue an existing conversation - they can't create new ones per se. As a result, you need to pre-install your bot for the relevant users. There are two main ways to do this:

  1. Using Teams Policy - this requires an Admin, in the Teams Admin centre - see more here: https://learn.microsoft.com/en-us/microsoftteams/teams-app-setup-policies#install-apps . This option is the easiest, fastest, and most simple, but might not be available (e.g. no access to Teams Admin)
  2. The other option is to use the Microsoft Graph to auto-install the app for the user. To do this, here's the reference: https://learn.microsoft.com/en-us/graph/api/userteamwork-post-installedapps?view=graph-rest-1.0&tabs=http

Both of these approaches will work fine for an organisational app too - they don't need to be in the actual Teams Store

Hilton Giesenow
  • 9,809
  • 2
  • 10
  • 24
  • So I believe there is no turnaround other than the installation of the apps for the user. Can you please tell me what are this user id specifies in this graphi api document you provided `POST /users/{user-id | user-principal-name}/teamwork/installedApps`. – zack_dilan Mar 22 '22 at 11:10
  • I haven't tested this 100%, but I'm pretty sure that would be the user's Azure AD Object ID (it's the same id that you would get if the user installed the app directly). Note that you can use 'user principle name' instead though, which in most cases is basically their email address. – Hilton Giesenow Mar 22 '22 at 11:49
  • @HiltonGiesenow Thanks, it would be nice if you can clarify one last doubt. Is it possible for the bot to initiate a conversation other than getting conversation references by the above methods we discussed? like adding it in teams or installing the app in any context? using just the email id of the user alone?. – zack_dilan Mar 24 '22 at 14:19
  • no, unfortunately not - there needs to be an existing context. I presume this is probably for security reasons, otherwise random bots could message random users across any tenant. – Hilton Giesenow Mar 24 '22 at 14:22
0

The proactive messages are like three types in major

  1. Welcome messages
  2. Notification
  3. Schedules

These messages are given by the bot that are not in response to a particular question by the user The bot have access to all the dependent applications and the users, group chats and teams channel. First you need to create the bot and install in the location. For example if person 1 is getting response, his device or application must be having the plugin installed of the bot. For further reference check the document document2

Sairam Tadepalli
  • 1,563
  • 1
  • 3
  • 11
  • Thanks, Sairam. I completely understand what you meant. Maybe my question is quite confusing. I want to initiate the conversation by a bot saying that the bot is not installed in the location. Is it even possible to initiate a conversation using some other contact details like email id eg.? – zack_dilan Mar 22 '22 at 10:41
  • As per several documentations from microsoft, without installing the bot on the location, it's quite not possible to perform proactive messaging. – Sairam Tadepalli Mar 22 '22 at 11:11