I would love for this documentation to explain how a serviceUrl maps to tenants, teams and users. This would help me understand how to best model my data and it would help me understand whether I can use the service URL from user 1 to send a message to user 2.
If I get a service URL from a conversation update from a user in team ID TEA1 and tenant ID TEN1 , then:
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
I'll need to do a little research. Hopefully, I'll have an answer within a day or two.
@gabrielmdeal A serviceUrl maps to a conversation. In a Teams context, the serviceUrl maps to the conversation thread. In a group context and one-on-one context, there’s no thread so the serviceUrl just maps to the entire conversation.
Assuming you are designing a Teams channel bot, to communicate 1:1 with a user who is in a Team, fetch the roster for that team (using the TeamsInfo.getPagedMembers method) and create 1:1 conversations for each user. The 57.teams-conversation-bot sample demonstrates how to do this.
From bots/teamsConversationBot.js
async messageAllMembersAsync(context) {
const members = await this.getPagedMembers(context);
members.forEach(async (teamMember) => {
const message = MessageFactory.text(`Hello ${ teamMember.givenName } ${ teamMember.surname }. I'm a Teams conversation bot.`);
var ref = TurnContext.getConversationReference(context.activity);
ref.user = teamMember;
await context.adapter.createConversation(ref,
async (t1) => {
const ref2 = TurnContext.getConversationReference(t1.activity);
await t1.adapter.continueConversation(ref2, async (t2) => {
await t2.sendActivity(message);
});
});
});
await context.sendActivity(MessageFactory.text('All messages have been sent.'));
}
async getPagedMembers(context) {
var continuationToken;
var members = [];
do {
var pagedMembers = await TeamsInfo.getPagedMembers(context, 100, continuationToken);
continuationToken = pagedMembers.continuationToken;
members.push(...pagedMembers.members);
} while (continuationToken !== undefined);
return members;
}
A serviceUrl maps to a conversation. In a Teams context, the serviceUrl maps to the conversation thread. In a group context and one-on-one context, there’s no thread so the serviceUrl just maps to the entire conversation.
So my bot could receive two messages that are from the same user, in the same team, sent at the same time, but from different threads, and the service URLs for those two messages could be different? For example, the two service URLs might be https://smba.trafficmanager.net/amer and https://smba.trafficmanager.net/emea? That surprises me, I assumed service URLs were used to partition users into regional datastores.
I'm sorry; I passed along some incorrect information.
The service URL does NOT map to a conversation, but rather just to a regionalized server. the URL does not change based on conversation type. However, the service URL isn't stable (in that it can change). The code snippet from sample 57 is the recommended way to create 1:1 conversations for different users in a Teams group conversation.
I don't currently have information on when the service URL might change or at what level in the conversation hierarchy it would be stable. Let me know if you need that information, and I can update this thread when I hear more.
My original question boils down to, "Can a tenant have multiple service URLs? And if so, then can a team have multiple service URLs?" (I know service URLs can change over time, but that is not what I am talking about.) And, yes, I still wonder this.
At this point a tenant should not have multiple service URLs.
Let me know if I can help you track down more information. I'm sorry this took so long.
That is what I needed to know. Thanks!
Is that "At this point..." quote from documentation that I missed?
The "At this point a tenant should not have multiple service URLs" quote was from my contact on the team. I'll make sure it gets into the docs.