async def on_message_activity(self, turn_context: TurnContext): if turn_context.activity.text: text = turn_context.activity.text.lower() if "end" in text or "stop" in text: # Send End of conversation at the end. await turn_context.send_activity( MessageFactory.text("Ending conversation from the skill...") ) end_of_conversation = Activity(type=ActivityTypes.end_of_conversation) end_of_conversation.code = EndOfConversationCodes.completed_successfully await turn_context.send_activity(end_of_conversation) elif text == "botaction": await self._send_adaptive_card(turn_context, "botaction") elif text == "taskmodule": await self._send_adaptive_card(turn_context, "taskmodule") elif text == "submit": await self._send_adaptive_card(turn_context, "submit") elif text == "hero": await self._send_hero_card(turn_context) else: await turn_context.send_activity( MessageFactory.text(f"Send me botaction, taskmodule, submit, or hero for the respective card.") ) await turn_context.send_activity( MessageFactory.text( f'Say "end" or "stop" and I\'ll end the conversation and back to the parent.' ) ) else: await turn_context.send_activity(MessageFactory.text(f"The value of the activity was {turn_context.activity.value}"))
async def _send_eoc_to_parent(self, turn_context: TurnContext, error: Exception): try: # Send an EndOfConversation activity to the skill caller with the error to end the conversation, # and let the caller decide what to do. end_of_conversation = Activity(type=ActivityTypes.end_of_conversation) end_of_conversation.code = "SkillError" end_of_conversation.text = str(error) await turn_context.send_activity(end_of_conversation) except Exception as exception: print( f"\n Exception caught on _send_eoc_to_parent : {exception}", file=sys.stderr, ) traceback.print_exc()
async def on_message_activity(self, turn_context: TurnContext): print(turn_context.activity.conversation.id) if self.is_component_active(): await self.call_active_component(turn_context) return else: self.conversation_state.active_component = turn_context.activity.text await self.activate_component(turn_context, self.conversation_state.active_component) if not self.conversation_state.active_component: end_of_conversation = Activity( type=ActivityTypes.end_of_conversation) end_of_conversation.code = EndOfConversationCodes.completed_successfully await turn_context.send_activity(end_of_conversation)
async def on_message_activity(self, turn_context: TurnContext): if "end" in turn_context.activity.text or "exit" in turn_context.activity.text: # Send End of conversation at the end. await turn_context.send_activity( MessageFactory.text("Ending conversation from the skill...")) end_of_conversation = Activity( type=ActivityTypes.end_of_conversation) end_of_conversation.code = EndOfConversationCodes.completed_successfully await turn_context.send_activity(end_of_conversation) else: await turn_context.send_activity( MessageFactory.text(f"Echo: {turn_context.activity.text}")) await turn_context.send_activity( MessageFactory.text( f'Say "end" or "exit" and I\'ll end the conversation and back to the parent.' ))
async def on_message_activity(self, turn_context: TurnContext): await turn_context.send_activity( MessageFactory.text( "You can say \"end\" or \"stop\" to end the conversation")) if turn_context.activity.text == "end" or turn_context.activity.text == "stop": await turn_context.send_activity( MessageFactory.text("Ending conversation from the skill...")) end_of_conversation = Activity( type=ActivityTypes.end_of_conversation) end_of_conversation.code = EndOfConversationCodes.completed_successfully await turn_context.send_activity(end_of_conversation) else: await DialogHelper.run_dialog( self.dialog, turn_context, self.conversation_state.create_property("DialogState"), )
async def on_message_activity(self, turn_context: TurnContext): if "end" in turn_context.activity.text or "stop" in turn_context.activity.text: # Send End of conversation at the end. await turn_context.send_activity( MessageFactory.text("Ending conversation from the skill...")) end_of_conversation = Activity( type=ActivityTypes.end_of_conversation) end_of_conversation.code = EndOfConversationCodes.completed_successfully await turn_context.send_activity(end_of_conversation) else: self._add_conversation_reference(turn_context.activity) await turn_context.send_activity( MessageFactory.text( f"Visit http://localhost:39783/api/notify to proactively message all users who have messaged this bot." )) await turn_context.send_activity( MessageFactory.text( f'Say "end" or "stop" and I\'ll end the conversation and back to the parent.' ))
async def _end_skill_conversation( self, turn_context: TurnContext, error: Exception # pylint: disable=unused-argument ): if not self._skill_client or not self._skill_config: return try: # Inform the active skill that the conversation is ended so that it has a chance to clean up. # Note: the root bot manages the ActiveSkillPropertyName, which has a value while the root bot # has an active conversation with a skill. active_skill = await self._conversation_state.create_property( MainDialog.ACTIVE_SKILL_PROPERTY_NAME).get(turn_context) if active_skill: bot_id = self._config.APP_ID end_of_conversation = Activity( type=ActivityTypes.end_of_conversation) end_of_conversation.code = "RootSkillError" TurnContext.apply_conversation_reference( end_of_conversation, TurnContext.get_conversation_reference( turn_context.activity), True, ) await self._conversation_state.save_changes(turn_context, True) await self._skill_client.post_activity_to_skill( bot_id, active_skill, self._skill_config.SKILL_HOST_ENDPOINT, end_of_conversation, ) except Exception as exception: print( f"\n Exception caught on _end_skill_conversation : {exception}", file=sys.stderr, ) traceback.print_exc()
async def on_message_activity(self, turn_context: TurnContext): if "auth" in turn_context.activity.text or "yes" in turn_context.activity.text: await DialogHelper.run_dialog( self.dialog, turn_context, self.conversation_state.create_property("DialogState"), ) elif "end" in turn_context.activity.text or "stop" in turn_context.activity.text: # Send End of conversation at the end. await turn_context.send_activity( MessageFactory.text("Ending conversation from the skill...")) end_of_conversation = Activity( type=ActivityTypes.end_of_conversation) end_of_conversation.code = EndOfConversationCodes.completed_successfully await turn_context.send_activity(end_of_conversation) else: await turn_context.send_activity( MessageFactory.text(f"Echo: {turn_context.activity.text}")) await turn_context.send_activity( MessageFactory.text( f'Say "end" or "stop" and I\'ll end the conversation and back to the parent.' ))