assistant

Platypush documentation

assistant#

class platypush.message.event.assistant.AlarmEndEvent(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#

Bases: AlertEndEvent

Event triggered when an alarm ends on the assistant

__init__(*args, assistant: str | AssistantPlugin | None = None, **kwargs)#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.AlarmStartedEvent(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#

Bases: AlertStartedEvent

Event triggered when an alarm starts on the assistant

__init__(*args, assistant: str | AssistantPlugin | None = None, **kwargs)#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.AlertEndEvent(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when an alert ends on the assistant

__init__(*args, assistant: str | AssistantPlugin | None = None, **kwargs)#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.AlertStartedEvent(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when an alert starts on the assistant

__init__(*args, assistant: str | AssistantPlugin | None = None, **kwargs)#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.AssistantEvent(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#

Bases: Event

Base class for assistant events

__init__(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()[source]#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.ConversationEndEvent(*args, with_follow_on_turn: bool = False, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when a conversation ends

__init__(*args, with_follow_on_turn: bool = False, **kwargs)[source]#
Parameters:

with_follow_on_turn – Set to true if the conversation expects a user follow-up, false otherwise

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.ConversationStartEvent(*args, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when a new conversation starts

__init__(*args, **kwargs)[source]#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.ConversationTimeoutEvent(*args, **kwargs)[source]#

Bases: ConversationEndEvent

Event triggered when a conversation times out

__init__(*args, **kwargs)[source]#
Parameters:

with_follow_on_turn – Set to true if the conversation expects a user follow-up, false otherwise

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.HotwordDetectedEvent(*args, hotword: str | None = None, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when a custom hotword is detected

__init__(*args, hotword: str | None = None, **kwargs)[source]#
Parameters:

hotword – The detected user hotword.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.IntentRecognizedEvent(*args, intent: str, slots: Mapping[str, Any] | None = None, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when an intent is matched by a speech command.

__init__(*args, intent: str, slots: Mapping[str, Any] | None = None, **kwargs)[source]#
Parameters:
  • intent – The intent that has been matched.

  • slots – The slots extracted from the intent, as a key-value mapping.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)[source]#

Overrides matches condition, and stops the conversation to prevent the default assistant response if the event matched some event hook condition.

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.MicMutedEvent(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when the microphone is muted.

__init__(*args, assistant: str | AssistantPlugin | None = None, **kwargs)#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.MicUnmutedEvent(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when the microphone is muted.

__init__(*args, assistant: str | AssistantPlugin | None = None, **kwargs)#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.NoResponseEvent(*args, with_follow_on_turn: bool = False, **kwargs)[source]#

Bases: ConversationEndEvent

Event triggered when a conversation ends with no response

__init__(*args, with_follow_on_turn: bool = False, **kwargs)#
Parameters:

with_follow_on_turn – Set to true if the conversation expects a user follow-up, false otherwise

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.ResponseEndEvent(*args, response_text: str, with_follow_on_turn: bool = False, **kwargs)[source]#

Bases: ConversationEndEvent

Event triggered when a response has been rendered on the assistant.

__init__(*args, response_text: str, with_follow_on_turn: bool = False, **kwargs)[source]#
Parameters:
  • response_text – Response text rendered on the assistant.

  • with_follow_on_turn – Set to true if the conversation expects a user follow-up, false otherwise.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.ResponseEvent(*args, response_text: str, with_follow_on_turn: bool = False, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when a response is processed by the assistant

__init__(*args, response_text: str, with_follow_on_turn: bool = False, **kwargs)[source]#
Parameters:
  • response_text – Response text processed by the assistant

  • with_follow_on_turn – Set to true if the conversation expects a user follow-up, false otherwise

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.SpeechRecognizedEvent(*args, phrase: str, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when a speech is recognized

__init__(*args, phrase: str, **kwargs)[source]#
Parameters:

phrase – Recognized user phrase

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)[source]#

Overrides matches condition, and stops the conversation to prevent the default assistant response if the event matched some event hook condition.

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.TimerEndEvent(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#

Bases: AlertEndEvent

Event triggered when a timer ends on the assistant

__init__(*args, assistant: str | AssistantPlugin | None = None, **kwargs)#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.TimerStartedEvent(*args, assistant: str | AssistantPlugin | None = None, **kwargs)[source]#

Bases: AlertStartedEvent

Event triggered when a timer starts on the assistant

__init__(*args, assistant: str | AssistantPlugin | None = None, **kwargs)#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.assistant.VolumeChangedEvent(*args, volume: float, **kwargs)[source]#

Bases: AssistantEvent

Event triggered when the volume of the assistant changes.

__init__(*args, volume: float, **kwargs)[source]#
Parameters:

assistant – Name of the assistant plugin that triggered the event.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object