1

I have an PHP application that should send proactive messages to individual MS Teams users and send notifications to Teams channel as well. I spent a lot of time reading docs but totally got stack with one-way notification bot for MS Teams.

What done:
I created app with bot by App Studio and register it at botframework. So now I can install it to my Teams.

My questions:
Is is possible to send proactive messages with PHP (without SDK, Rest API) and how create that kind of bot? I can get an token from Rest API but how to identify team and start proactive conversation?

3
  • I am not fully into that topic, but you may create webhooks to do so. Commented Jul 24, 2020 at 10:43
  • It is not that I need. I need to send proactive messages to user from php. Commented Jul 24, 2020 at 10:50
  • But as far as I know you can setup a webhook/connector exactly doing that. Commented Jul 24, 2020 at 10:52

1 Answer 1

2

This is a bit of a troublesome topic for exactly this reason - the docs explain how to Send the message, but not that there are critical variables you need, and that you need to have them already, for instance "ServiceUrl" and "ConversationId". They are unique to every user (for 1-1 chat) or for every conversation. You can get these any time the user calls your bot (they are on the "Activity" object), but also right as your app is installed by the user - there is a "ConversationUpdate" event call that is sent, that contains them too. You then need to store them your side (e.g. in a database), for later use in sending the actual 'proactive message'.

Hopefully that gives you what you need, but if anything is still unclear let me know in the "comments"

Sign up to request clarification or add additional context in comments.

13 Comments

Thanks for your answer! Do not sure that I understand what is "app is installed by the user". Probably my post above is not entirely accurate, here is a full description what I need: I have an PHP webservice with users. When some events occurs at the PHP webservice: 1. Send notification to user (I have only email so find user at MS Teams by email). 2. Send notification to special predefined channel. In my flow MS Teams users do not interact with my Bot and I need somehow initiate notification. So I need to somehow initiate install MS Team app from PHP webservice once (OUATH?)
let me try explain better. If you only want to send messages to a channel, then the incoming webhook is fine. If you want to send to both users directly (i.e. "1-1") as well as to Channels, then you need to create a bot. When a user adds the bot to the channel, your bot will receive the "ConversationUpdate" event, and it can save certain details out of there, to send the proactive message later. For the 1-1 proactive messaging to work, each of the users must also install the bot themselves, as a personal app. Each of those installation will also fire it's own "ConversationUpdate" event
does that explain better?
@HiltonGiesenow It took me a week to figure all this out, I started building a MS Team app using REST API 2 weeks back and I am still building it. What you have written is something I was able to figure out and now just working on it. Though there is 1 thing I have not been able to find is that -> Is there a Bot API to create a channel and add members to it?
sure, glad to help. Please be sure to upvote or mark as answer, so others with a similar issue can see that this was helpful
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.