Home

How to obtain the current value of serviceUrl for a bot?

%3CLINGO-SUB%20id%3D%22lingo-sub-283679%22%20slang%3D%22en-US%22%3EHow%20to%20obtain%20the%20current%20value%20of%20serviceUrl%20for%20a%20bot%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-283679%22%20slang%3D%22en-US%22%3E%3CP%3EHello!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20working%20on%20a%20plugin%20that%20integrates%20with%20Microsoft%20Teams.%20I'd%20like%20to%20post%20messages%20to%20channels.%20I%20have%20created%20a%20simple%20Python%20script%20that%20uses%20REST%20API%20to%20do%20that.%20It%26nbsp%3Bgoes%20through%20the%20following%20steps%3A%3C%2FP%3E%3CP%3E*%20authenticate%20(using%20app%20ID%20and%20app%20password%20from%20bot%20configuration%2C%20endpoint%3A%20%3CA%20href%3D%22https%3A%2F%2Flogin.microsoftonline.com%2Fbotframework.com%2Foauth2%2Fv2.0%2Ftoken%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Flogin.microsoftonline.com%2Fbotframework.com%2Foauth2%2Fv2.0%2Ftoken%3C%2FA%3E)%3C%2FP%3E%3CP%3E*%20keep%20the%20token%20for%20all%20further%20API%20calls%3C%2FP%3E%3CP%3E*%20get%20a%20list%20of%20all%20channels%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsmba.trafficmanager.net%2Femea%2Fv3%2Fteams%2F%7BTEAM_ID%7D%2Fconversations%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsmba.trafficmanager.net%2Femea%2Fv3%2Fteams%2F%7BTEAM_ID%7D%2Fconversations%3C%2FA%3E%3C%2FP%3E%3CP%3E*%20find%20a%20channel%20ID%20for%20a%20channel%20with%20a%20specific%20name%20(in%20my%20case%20'test_channel')%3C%2FP%3E%3CP%3E*%20send%20a%20message%20to%20that%20channel%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3Eresp%20%3D%20post(%3CBR%20%2F%3E%20'https%3A%2F%2Fsmba.trafficmanager.net%2Femea%2Fv3%2Fconversations%2F%7B%7D%2Factivities'.format(test_channel_id)%2C%3CBR%20%2F%3E%20json%3D%7B%3CBR%20%2F%3E%20'type'%3A%20'message'%2C%3CBR%20%2F%3E%20'conversation'%3A%20%7B'id'%3A%20test_channel_id%7D%2C%3CBR%20%2F%3E%20'text'%3A%20'From%20Python'%3CBR%20%2F%3E%20%7D%2C%3CBR%20%2F%3E%20headers%3D%7B'Authorization'%3A%20'Bearer%20%7B%7D'.format(token)%7D%3CBR%20%2F%3E)%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20example%20works.%20There%20is%20just%20one%20problem%3A%20the%20value%20of%20serviceUrl%20(%3CA%20href%3D%22https%3A%2F%2Fsmba.trafficmanager.net%2Femea%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsmba.trafficmanager.net%2Femea%3C%2FA%3E).%20It%20has%20been%20obtained%20by%20me%20from%20a%20previous%20message%20sent%20to%20my%20bot.%20From%20what%20I've%20learned%20from%20the%20documentation%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fplatform%2Fconcepts%2Fapps%2Fapps-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fplatform%2Fconcepts%2Fapps%2Fapps-overview%3C%2FA%3E)%20the%20value%20can%20change%20at%20any%20time%20and%20it's%20better%20to%20update%20it%26nbsp%3Beach%20time%26nbsp%3Bthe%20bot%20receives%20a%20message.%20However%2C%26nbsp%3Bit's%20possible%20that%20my%20bot%20will%20not%20receive%20regular%20messages%20or%20any%20messages%20at%20all%20(it%20will%20only%20be%20used%20for%20sending%20messages).%20In%20that%20case%20how%20can%20I%20make%20sure%20that%20the%20value%20of%20serviceUrl%20is%20up%20to%20date%3F%20Is%20there%20an%20endpoint%20I%20can%20call%20to%20receive%20the%20current%20version%20of%20serviceUrl%3F%20Shall%20I%20use%20connectors%20instead%20of%20bots%20for%20this%20case%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3CP%3ECharlie%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-283679%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBots%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EConversations%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-325364%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20obtain%20the%20current%20value%20of%20serviceUrl%20for%20a%20bot%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-325364%22%20slang%3D%22en-US%22%3EI%20would%20like%20the%20answer%20to%20this%20question%20as%20well.%20If%20anyone%20knows%20of%20a%20way%20please%20let%20us%20know!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-671444%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20obtain%20the%20current%20value%20of%20serviceUrl%20for%20a%20bot%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-671444%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239585%22%20target%3D%22_blank%22%3E%40Charlie%20Kane%3C%2FA%3EDo%20you%20or%20anyone%20else%20have%20an%20update%20on%20this%3F%20I%20would%20also%20need%20to%20know%20this.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-740718%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20obtain%20the%20current%20value%20of%20serviceUrl%20for%20a%20bot%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-740718%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239585%22%20target%3D%22_blank%22%3E%40Charlie%20Kane%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F355203%22%20target%3D%22_blank%22%3E%40Sven1010%3C%2FA%3E%26nbsp%3Bdid%20you%20guys%20manage%20to%20figure%20that%20out%3F%20also%20looking%20for%20the%20solution%20for%20this%3C%2FP%3E%3C%2FLINGO-BODY%3E
Charlie Kane
Occasional Contributor

Hello!

 

I'm working on a plugin that integrates with Microsoft Teams. I'd like to post messages to channels. I have created a simple Python script that uses REST API to do that. It goes through the following steps:

* authenticate (using app ID and app password from bot configuration, endpoint: https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token)

* keep the token for all further API calls

* get a list of all channels: https://smba.trafficmanager.net/emea/v3/teams/{TEAM_ID}/conversations

* find a channel ID for a channel with a specific name (in my case 'test_channel')

* send a message to that channel:

 

resp = post(
'https://smba.trafficmanager.net/emea/v3/conversations/{}/activities'.format(test_channel_id),
json={
'type': 'message',
'conversation': {'id': test_channel_id},
'text': 'From Python'
},
headers={'Authorization': 'Bearer {}'.format(token)}
)

 

This example works. There is just one problem: the value of serviceUrl (https://smba.trafficmanager.net/emea). It has been obtained by me from a previous message sent to my bot. From what I've learned from the documentation (https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/apps/apps-overview) the value can change at any time and it's better to update it each time the bot receives a message. However, it's possible that my bot will not receive regular messages or any messages at all (it will only be used for sending messages). In that case how can I make sure that the value of serviceUrl is up to date? Is there an endpoint I can call to receive the current version of serviceUrl? Shall I use connectors instead of bots for this case?

 

Best regards,

Charlie

3 Replies
I would like the answer to this question as well. If anyone knows of a way please let us know!

@Charlie KaneDo you or anyone else have an update on this? I would also need to know this.

@Charlie Kane @Sven1010 did you guys manage to figure that out? also looking for the solution for this

Related Conversations
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
2 Replies
*Updated 9/3* Syncing in Microsoft Edge Preview Channels
Elliot Kirk in Articles on
202 Replies
Early preview of Microsoft Edge group policies
Sean Lyndersay in Discussions on
65 Replies