1
votes

I want to build one way bot, the bot will be sending notifications to MS teams channel. I was able to accomplish this as mentioned in this post Initiate Proactive Conversation with Bot Framework for Microsoft Teams without Teams-Context possible?. But I see service url is not same in activity for all the requests and in docs it mentioned that it may change. How can I able to get correct service url without user initiating the request first.

If first scenario is not possible, if we store service url first time user send message to bot , how do we know if it changes without checking service url in each activity request.

1
@ranusharao From the docs it isn't clear when the serviceUrl will change. - Mahesh
Can you elaborate on the use case where this is needed? - Jos Verlinde
@JosVerlinde I want my bot to send notifications to channel without user initiating the conversation. - Mahesh

1 Answers

0
votes

ServiceUrl is the Url to which our proactive messaging code should send all the requests. This Url is sent by Teams in the Bot payload in the turnContext.Activity.serviceUrl property. For all intents and purposes this url will remain constant but very rarely this url might change and our bot should have the logic for updating the stored base url periodically from the payload sent to the bot. More about the Base Url here: https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#base-uri

If the service URL changes, previous conversation references will no longer be valid and calls to continue conversation will generate an error or exception. In this case, your bot will need to acquire a new conversation reference for the user before it can send proactive messages again.