diff --git a/platypush/backend/assistant/google/__init__.py b/platypush/backend/assistant/google/__init__.py index a2fd69d6..d6c4264e 100644 --- a/platypush/backend/assistant/google/__init__.py +++ b/platypush/backend/assistant/google/__init__.py @@ -12,7 +12,7 @@ from google.assistant.library.file_helpers import existing_file from platypush.backend import Backend from platypush.message.event.assistant import \ ConversationStartEvent, ConversationEndEvent, ConversationTimeoutEvent, \ - NoResponseEvent, SpeechRecognizedEvent + ResponseEvent, NoResponseEvent, SpeechRecognizedEvent class AssistantGoogleBackend(Backend): @@ -46,11 +46,14 @@ class AssistantGoogleBackend(Backend): if event.type == EventType.ON_CONVERSATION_TURN_STARTED: self.bus.post(ConversationStartEvent()) elif event.type == EventType.ON_CONVERSATION_TURN_FINISHED: - self.bus.post(ConversationEndEvent()) + if not event.args.get('with_follow_on_turn'): + self.bus.post(ConversationEndEvent()) elif event.type == EventType.ON_CONVERSATION_TURN_TIMEOUT: self.bus.post(ConversationTimeoutEvent()) elif event.type == EventType.ON_NO_RESPONSE: self.bus.post(NoResponseEvent()) + elif event.type == EventType.ON_RENDER_RESPONSE: + self.bus.post(ResponseEvent(response_text=event.args.get('text'))) elif event.type == EventType.ON_RECOGNIZING_SPEECH_FINISHED: phrase = event.args['text'].lower().strip() self.logger.info('Speech recognized: {}'.format(phrase)) diff --git a/platypush/message/event/assistant/__init__.py b/platypush/message/event/assistant/__init__.py index 849baadf..149326d7 100644 --- a/platypush/message/event/assistant/__init__.py +++ b/platypush/message/event/assistant/__init__.py @@ -37,6 +37,11 @@ class ConversationTimeoutEvent(ConversationEndEvent): super().__init__(*args, **kwargs) +class ResponseEvent(ConversationEndEvent): + def __init__(self, response_text, *args, **kwargs): + super().__init__(*args, response_text=response_text, **kwargs) + + class NoResponseEvent(ConversationEndEvent): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs)