Closed MasonStricklin closed 3 years ago
Hi @MasonStricklin, I will repro at my and will let you know.
Let me know if there is any info that I could provide that could help.
Edit: apologies below, mis-clicked and closed the issue.
Hi @MasonStricklin Could you please send the conversationUpdate event method code snippet.
Here is a snippet taken from the controller where I handle conversationUpdate/membersAdded events. Our app is ruby on rails fyi.
I also posted this issue on Stackoverflow. I went more in depth describing the problem here, so it might be worth taking a look at my SO post too (link).
# POST /microsoft-teams/events
#
# This is the callback URL we provide to Microsoft in their Bot Framework tool,
# which allows them to ping us when our bot is added to a channel, removed from
# a channel, or mentioned/receives a command. Our bot will send a welcome message
# when added to a channel
#
def events
recipient_id = params.dig(:recipient, :id)
return head :bad_request if !recipient_id.include?(Settings.microsoft.oauth_client_id)
members_added = params.dig(:membersAdded) || []
qualified_bot_added_to_team = members_include_qualified_bot?(members_added)
members_removed = params.dig(:membersRemoved) || []
qualified_bot_removed_from_team = members_include_qualified_bot?(members_removed)
general_channel_id = params.dig(:conversation, :id)
service_url = params.dig(:serviceUrl)
tenant_id = params.dig(:conversation, :tenantId)
team_id = params.dig(:channelData, :team, :aadGroupId)
if (general_channel_id.nil? || service_url.nil? || tenant_id.nil?)
raise ArgumentError, 'Invalid request parameters in MicrosoftTeamsController'
head :bad_request
elsif ((qualified_bot_added_to_team || qualified_bot_removed_from_team) && team_id.nil?)
raise ArgumentError, 'Missing team_id in request parameters in MicrosoftTeamsController',
head :bad_request
else
if (qualified_bot_added_to_team || qualified_bot_removed_from_team)
# SAVE SERVICE URL HERE
# SAVE WHETHER THIS TEAM HAS APP INSTALLED HERE
end
if qualified_bot_added_to_team
# SEND MESSAGE TO GENERAL CHANNEL HERE
end
head :ok
end
end
def members_include_qualified_bot?(members_list)
members_list.any? { |m| m.include?(:id) && m[:id].include?(Settings.microsoft.oauth_client_id) }
end
Thanks for taking a look at this, I appreciate it!
Hi @MasonStricklin - I am unable to repro the issue. I am getting conversationUpdate event when our bot is installed for a team. I have added my bot to multiple teams and I am getting welcome message.
If the bot added already to teams then you will not receive welcome message.
@MasonStricklin - Thank you for the code sample.
How did you determine that the bot isn't receiving conversation updates? Is it possible that the bot is receiving the conversation update activities but just isn't responding to them correctly? Could it just be encountering errors perhaps?
@MasonStricklin - following up to see if you need additional support with this issue?
Resolving issue for now due to lack of response from OP.
Hello,
My Microsoft Teams Bot (listed in AppSource here: link) does not always receive the conversationUpdate event when a bot is installed for a team.
I have a user who installed our app to one team. Our app received the conversationUpdate event and we triggered a welcome message to the general channel of that team.
They then went to install our bot in a couple of other teams. We have not received the conversationUpdate event for these other teams, which means they did not receive the welcome message.
Is there any reason why we would receive a conversationUpdate event for the first team they installed our app to, but not subsequent teams? They have tried uninstalling and reinstalling, but that does not seem to trigger the conversationUpdate event.
Could it have something to do with how they created these teams? Or perhaps there is a setting they have enabled that could impact this?