@@ -244,6 +244,8 @@ async def _send_to_skill(
244244 # Process replies in the response.Body.
245245 response .body : List [Activity ]
246246 response .body = ExpectedReplies ().deserialize (response .body ).activities
247+ # Track sent invoke responses, so more than one is not sent.
248+ sent_invoke_response = False
247249
248250 for from_skill_activity in response .body :
249251 if from_skill_activity .type == ActivityTypes .end_of_conversation :
@@ -254,12 +256,18 @@ async def _send_to_skill(
254256 await self .dialog_options .conversation_id_factory .delete_conversation_reference (
255257 skill_conversation_id
256258 )
257- elif await self ._intercept_oauth_cards (
259+ elif not sent_invoke_response and await self ._intercept_oauth_cards (
258260 context , from_skill_activity , self .dialog_options .connection_name
259261 ):
260- # do nothing. Token exchange succeeded, so no oauthcard needs to be shown to the user
261- pass
262+ # Token exchange succeeded, so no oauthcard needs to be shown to the user
263+ sent_invoke_response = True
262264 else :
265+ # If an invoke response has already been sent we should ignore future invoke responses as this
266+ # represents a bug in the skill.
267+ if from_skill_activity .type == ActivityTypes .invoke_response :
268+ if sent_invoke_response :
269+ continue
270+ sent_invoke_response = True
263271 # Send the response back to the channel.
264272 await context .send_activity (from_skill_activity )
265273
0 commit comments