When trying to init a conversation and send a user a notification in Production, I receive the following error:
Microsoft.Bot.Schema.ErrorResponseException: Operation returned an invalid status code 'Forbidden'
Update: after further debugging, the message inside the error response exception reads:
The bot is not part of the conversation roster.
During local development connecting to a test app in MS Teams, it works fine. It also worked fine up until last Friday - then suddenly stopped with no code changes.
The code below was based on this example from Microsoft and it's intention is to send a welcome card to a user during the teamMembersAdded
event. Am I doing anything wrong here?
// Retrieve and validate channel data
var channelData = turnContext.Activity.GetChannelData<TeamsChannelData>();
if (channelData.Team == null)
{
logger.LogInformation("Not sending welcome card as Team in payload is null");
return;
}
// Setup connector and trust url
MicrosoftAppCredentials.TrustServiceUrl(turnContext.Activity.ServiceUrl);
var connector = new ConnectorClient(new System.Uri(turnContext.Activity.ServiceUrl), _credentials);
// Starts new conversation in channel with welcome card
var conversationParameters = new ConversationParameters()
{
IsGroup = true,
ChannelData = new TeamsChannelData()
{
Channel = new ChannelInfo(channelData.Team.Id),
},
Activity = await CreateWelcomeCardTeamActivity(),
};
await connector.Conversations.CreateConversationAsync(conversationParameters);
Update 2: the bot works properly when added to an older team (one that was used for testing some time last year and earlier in this year) but not when added to any newer team.
The only difference seems to be that the older team uses the @thread.skype
ID suffix whereas the new teams all use the @thread.tacv2
ID suffix.