workflow
index
/home/runner/work/relay-py/relay-py/src/relay/workflow.py

A module for implementing Relay workflows in Python. This is the SDK that
provides a way for your enterprise to extend your I/T tools to your active
workers via Relay devices. There are APIs for text-to-speech (say),
speech-to-text (listen), LED control, vibration control, location
information, NFC tag taps, etc. See https://developer.relaypro.com

 
Modules
       
asyncio
json
logging
os
requests
ssl
time
urllib
uuid
websockets

 
Classes
       
builtins.Exception(builtins.BaseException)
ServerException
WorkflowException
builtins.object
Relay
Server
Workflow
logging.LoggerAdapter(builtins.object)
CustomAdapter

 
class CustomAdapter(logging.LoggerAdapter)
    CustomAdapter(logger, extra=None)
 

 
 
Method resolution order:
CustomAdapter
logging.LoggerAdapter
builtins.object

Methods defined here:
process(self, msg, kwargs)
Process the logging message and keyword arguments passed in to
a logging call to insert contextual information. You can either
manipulate the message itself, the keyword args or both. Return
the message and kwargs modified (or not) to suit your needs.
 
Normally, you'll only need to override this one method in a
LoggerAdapter subclass for your specific needs.

Methods inherited from logging.LoggerAdapter:
__init__(self, logger, extra=None)
Initialize the adapter with a logger and a dict-like object which
provides contextual information. This constructor signature allows
easy stacking of LoggerAdapters, if so desired.
 
You can effectively pass keyword arguments as shown in the
following example:
 
adapter = LoggerAdapter(someLogger, dict(p1=v1, p2="v2"))
__repr__(self)
Return repr(self).
critical(self, msg, *args, **kwargs)
Delegate a critical call to the underlying logger.
debug(self, msg, *args, **kwargs)
Delegate a debug call to the underlying logger.
error(self, msg, *args, **kwargs)
Delegate an error call to the underlying logger.
exception(self, msg, *args, exc_info=True, **kwargs)
Delegate an exception call to the underlying logger.
getEffectiveLevel(self)
Get the effective level for the underlying logger.
hasHandlers(self)
See if the underlying logger has any handlers.
info(self, msg, *args, **kwargs)
Delegate an info call to the underlying logger.
isEnabledFor(self, level)
Is this logger enabled for level 'level'?
log(self, level, msg, *args, **kwargs)
Delegate a log call to the underlying logger, after adding
contextual information from this adapter instance.
setLevel(self, level)
Set the specified level on the underlying logger.
warn(self, msg, *args, **kwargs)
warning(self, msg, *args, **kwargs)
Delegate a warning call to the underlying logger.

Class methods inherited from logging.LoggerAdapter:
__class_getitem__ = GenericAlias(...) from builtins.type
Represent a PEP 585 generic type
 
E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).

Readonly properties inherited from logging.LoggerAdapter:
name

Data descriptors inherited from logging.LoggerAdapter:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)
manager

 
class Relay(builtins.object)
    Relay(workflow: workflow.Workflow)
 
Includes the main functionalities that are used within workflows,
such as functions for communicating with the device, sending out
notifications to groups, handling workflow events, and performing physical actions
on the device such as manipulating LEDs and creating vibrations.
 
  Methods defined here:
__init__(self, workflow: workflow.Workflow)
Initializes workflow fields.
 
Args:
    workflow (Workflow): your workflow.
async alert(self, target, originator: str, name: str, text: str, push_opts: dict = None)
Sends out an alert to the specified group of devices and the Relay Dash.
 
Args:
    target(str): the group URN that you would like to send an alert to.
    originator (str): the URN of the device that triggered the alert.
    name (str): a name for your alert.
    text (str): the text that you would like to be spoken to the group as your alert.
    push_opts (dict, optional): push options for if the alert is sent to the Relay app on a virtual device.
     Defaults to an empty value.
async answer_call(self, target, call_id: str)
Answers an incoming call on your device.
 
Args:
    target (str): the device which will answer the call.
    call_id (str): the ID of the call to answer.
async breathe(self, target, color: str = '0000ff', count: int = -1)
Switches all the LEDs on a device to a certain color and creates a 'breathing' effect,
where the LEDs will slowly light up a specified number of times.
 
Args:
    target (str): the interaction URN.
    color (str, optional): the hex color code you would like to turn the LEDs to. Defaults to '0000ff'.
    count (int, optional): the number of times you would like the LEDs to 'breathe'. Defaults to -1, meaning
    the LEDs will 'breathe' indefinitely.
async broadcast(self, target, originator: str, name: str, text: str, push_opts: dict = None)
Sends out a broadcast message to a group of devices.  The message is played out on
all devices, as well as sent to the Relay Dash.
 
Args:
    target(str): the group URN that you would like to broadcast your message to.
    originator (str): the device URN that triggered the broadcast.
    name (str): a name for your broadcast.
    text (str): the text that you would like to be broadcasted to your group.
    push_opts (dict, optional): push options for if the broadcast is sent to the Relay app on a virtual
     device. Defaults to an empty value.
async cancel_alert(self, target, name: str)
Cancels an alert that was sent to a group of devices.  Particularly useful if you would like to cancel
 the alert on all devices after one device has acknowledged the alert.
 
Args:
    target(str): the device URN that has acknowledged the alert.
    name (str): the name of the alert.
async cancel_broadcast(self, target, name: str)
Cancels the broadcast that was sent to a group of devices.
 
Args:
    target(str): the device URN that is cancelling the broadcast.
    name (str): the name of the broadcast that you would like to cancel.
async clear_timer(self, name: str)
Clears the specified timer.
 
Args:
    name (str): the name of the timer that you would like to clear.
async create_incident(self, originator, itype: str)
Creates an incident that will alert the Relay Dash.
 
Args:
    originator (str): the device URN that triggered the incident.
    itype (str): the type of incident that occurred.
 
Returns:
    str: the incident ID.
async disable_home_channel(self, target)
async disable_location(self, target)
Disables location services on a device.  Location services will remain
disabled until they are enabled on the Relay Dash or through a workflow.
 
Args:
    target (str): the device or interaction URN.
async enable_home_channel(self, target)
async enable_location(self, target)
Enables location services on a device.  Location services will remain
enabled until they are disabled on the Relay Dash or through a workflow.
 
Args:
    target (str): the device or interaction URN.
async end_interaction(self, target)
Ends an interaction with the user.  Triggers an INTERACTION_ENDED event to signify
that the user is done interacting with the device.
 
Args:
    target(str): the interaction that you would like to end.
async flash(self, target, color: str = '0000ff', count: int = -1)
Switches all the LEDs on a device to a certain color and flashes them
a specified number of times.
 
Args:
    target (str): the interaction URN.
    color (str, optional): the hex color code you would like to turn the LEDs to. Defaults to '0000ff'.
    count (int, optional): the number of times you would like the LEDs to flash. Defaults to -1, meaning
     the LEDs will flash indefinitely.
async get_device_address(self, target, refresh: bool = False)
Returns the address of a targeted device.
 
Args:
    target (str): the device or interaction URN.
    refresh (bool, optional): whether you would like to refresh before retrieving the address.
     Defaults to False.
 
Returns:
    str: the address of the device.
async get_device_battery(self, target, refresh: bool = False)
Returns the battery of a targeted device.
 
Args:
    target (str): the device or interaction URN.
    refresh (bool, optional): whether you would like to refresh before retrieving the battery.
     Defaults to False.
 
Returns:
    int: the battery of the device.
async get_device_coordinates(self, target, refresh: bool = False)
Retrieves the coordinates of the device's location.
 
Args:
    target (str): the device or interaction URN.
    refresh (bool, optional): whether you would like to refresh before retreiving the coordinates.
     Defaults to False.
async get_device_id(self, target)
Returns the ID of a targeted device.
 
Args:
    target (str): the device or interaction URN.
 
Returns:
    str: the device ID.
async get_device_indoor_location(self, target, refresh: bool = False)
Returns the indoor location of a targeted device.
 
Args:
    target (str): the device or interaction URN.
    refresh (bool, optional): whether you would like to refresh before retrieving the location.
     Defaults to False.
 
Returns:
    str: the indoor location of the device.
async get_device_latlong(self, target, refresh: bool = False)
Returns the latitude and longitude coordinates of a targeted device.
 
Args:
    target (str): the device or interaction URN.
    refresh (bool, optional): whether you would like to refresh before retrieving the coordinates.
     Defaults to False.
 
Returns:
    float[]: an array containing the latitude and longitude of the device.
async get_device_location(self, target, refresh: bool = False)
Returns the location of a targeted device.
 
Args:
    target (str): the device or interaction URN.
    refresh (bool, optional): whether you would like to refresh before retrieving the location.
     Defaults to False.
 
Returns:
    str: the location of the device.
async get_device_location_enabled(self, target)
Returns whether the location services on a device are enabled.
 
Args:
    target (str): the device or interaction URN.
 
Returns:
    str: 'true' if the device's location services are enabled, 'false' otherwise.
async get_device_name(self, target)
Returns the name of a targeted device.
 
Args:
    target (str): the device or interaction URN.
 
Returns:
    str: the name of the device.
async get_device_type(self, target)
Returns the device type of a targeted device, i.e. gen 2, gen 3, etc.
 
Args:
    target (str): the device or interaction URN.
 
Returns:
    str: the device type.
async get_group_members(self, group_uri: str)
Returns the members of a particular group.
 
Args:
    group_uri (str): the URN of the group that you would like to retrieve members from.
 
Returns:
    str[]: a list of the members within the specified group.
async get_number_var(self, name: str, default=None)
Retrieves a variable that was set either during workflow registration
or through the set_var() function of type integer.  The variable can be retrieved anywhere
within the workflow, but is erased after the workflow terminates.
 
Args:
    name (str): name of the variable to be retrieved.
    default (optional): default value of the variable if it does not exist. Defaults to None.
 
Returns:
    the variable requested.
async get_unread_inbox_size(self, target)
Retrieves the number of messages in a device's inbox.
 
Args:
    target (str): the device or interaction URN whose inbox you would like to check.
 
Returns:
    str: the number of messages in the specified device's inbox.
async get_user_profile(self, target)
Returns the user profile of a targeted device.
 
Args:
    target (str): the device or interaction URN.
 
Returns:
    str: the user profile registered to the device.
async get_var(self, name: str, default=None)
Retrieves a variable that was set either during workflow registration
or through the set_var() function.  The variable can be retrieved anywhere
within the workflow, but is erased after the workflow terminates.
 
Args:
    name (str): name of the variable to be retrieved.
    default (optional): default value of the variable if it does not exist. Defaults to None.
 
Returns:
    the variable requested.
async hangup_call(self, target, call_id: str)
Ends (hangs up) a call on a device.
 
Args:
    target (str): the device which will do the hangup.
    call_id (str): the call ID.
async is_group_member(self, group_name_uri: str, potential_member_name_uri: str)
Checks whether a device is a member of a particular group.
 
Args:
    group_name_uri (str): the URN of a group.
    potential_member_name_uri: the URN of the device name.
 
Returns:
    str: 'true' if the device is a member of the specified group, 'false' otherwise.
async led_action(self, target, effect: str = 'flash', args=None)
Private method used for performing actions on the LEDs, such as creating 
a rainbow, flashing, rotating, etc.
 
Args:
    target (str): the interaction URN.
    effect (str, optional): effect to perform on LEDs, can be 'rainbow', 'rotate', 'flash', 'breath',
        'static', or 'off'. Defaults to 'flash'.
    args (optional): use led_info() to create args. Defaults to None.
async listen(self, target, phrases=None, transcribe: bool = True, alt_lang: str = None, timeout: int = 60)
Listens for the user to speak into the device.  Utilizes speech to text functionality to interact
with the user.
 
Args:
    target (str): the interaction URN.
    phrases (string[], optional): optional phrases that you would like to limit the user's response to.
     Defaults to None.
    transcribe (bool, optional): whether you would like to transcribe the user's reponse. Defaults to True.
    timeout (int, optional): timeout for how long the device will wait for user's response. Defaults to 60.
    alt_lang (str, optional): if you would like the device to listen for a response in a specific language.
     Defaults to None.
 
Returns:
    text representation of what the user had spoken into the device.
async log_message(self, message: str, category: Optional[str] = 'default', target: Optional[str] = None, content_type: Optional[str] = 'text/plain')
Log an analytics event from a workflow with the specified content and
under a specified category. This does not log the device who
triggered the workflow that called this function.
 
Args:
    message (str): a description for your analytical event.
    category (str, optional): a category for your analytical event. Defaults to 'default'.
    target (str, optional): URN of the device that triggered this function. Defaults to None.
    content_type (str, optional): encoding of the message string. Defaults to 'text/plain'.
async log_user_message(self, message: str, target, category: str)
Log an analytic event from a workflow with the specified content and
under a specified category.  This includes the device who triggered the workflow
that called this function.
 
Args:
    message (str): a description for your analytical event.
    target (str, optional): the URN of a the device that triggered this function. Defaults to None.
    category (str): a category for your analytical event.
async place_call(self, target, callee_uri: str)
Places a call to another device.
 
Args:
    target (str): the device which will place the call.
    callee_uri (str): the URN of the device you would like to call.
 
Returns:
    the event response.
async play(self, target, filename: str)
Plays a custom audio file that was uploaded by the user.
 
Args:
    target(str): the interaction URN.
    filename (str): the name of the audio file.
 
Returns:
    the response id after the audio file has been played on the device.
async play_and_wait(self, target, filename: str)
Plays a custom audio file that was uploaded by the user.
Waits until the audio file has finished playing before continuing through
the workflow.
 
Args:
    target(str): the interaction URN.
    filename (str): the name of the audio file.
 
Returns:
    the response id after the audio file has been played on the device.
async play_unread_inbox_messages(self, target)
Play a targeted device's inbox messages.
 
Args:
    target (str): the device or interaction URN whose inbox messages you would like to play.
async rainbow(self, target, rotations: int = -1)
Switches all the LEDs on to a configured rainbow pattern and rotates the rainbow
a specified number of times.
 
Args:
    target (str): the interaction URN.
    rotations (int, optional): the number of times you would like the rainbow to rotate. Defaults to -1,
     meaning the rainbow will rotate indefinitely.
async register(self, target, uri: str, password: str, expires: int)
# target can have only one item
async resolve_incident(self, incident_id: str, reason: str)
Resolves an incident that was created.
 
Args:
    incident_id (str): the ID of the incident you would like to resolve.
    reason (str): the reason for resolving the incident.
async rotate(self, target, color: str = '0000ff', rotations: int = -1)
Switches all the LEDs on a device to a certain color and rotates them a specified number
of times.
 
Args:
    target (str): the interaction URN.
    color (str, optional): the hex color code you would like to turn the LEDs to. Defaults to '0000ff'.
    rotations (int, optional): the number of times you would like the LEDs to rotate. Defaults to -1, meaning
    the LEDs will rotate indefinitely.
async say(self, target, text: str, lang: str = 'en-US')
Utilizes text to speech capabilities to make the device 'speak' to the user.
 
Args:
    target(str): the interaction URN.
    text (str): what you would like the device to say.
    lang (str, optional): the language of the text that is being spoken. Defaults to 'en-US'.
 
Returns:
    the response ID after the device speaks to the user.
async say_and_wait(self, target, text: str, lang: str = 'en-US')
Utilizes text to speech capabilities to make the device 'speak' to the user.
Waits until the text is fully played out on the device before continuing.
 
Args:
    target(str): the interaction URN.
    text (str): what you would like the device to say.
    lang (str, optional): the language of the text that is being spoken. Defaults to 'en-US'.
 
Returns:
    the response ID after the device speaks to the user.
async set_channel(self, target, channel_name: str, suppress_tts: bool = False, disable_home_channel: bool = False)
Sets the channel that a device is on.  This can be used to change the channel of a device during a workflow,
where the channel will also be updated on the Relay Dash.
 
Args:
    target (str): the device or interaction URN.
    channel_name (str): the name of the channel you would like to set your device to.
    suppress_tts (bool, optional): whether you would like to surpress text to speech. Defaults to False.
    disable_home_channel (bool, optional): whether you would like to disable the home channel.
     Defaults to False.
async set_device_name(self, target, name: str)
Sets the name of a targeted device and updates it on the Relay Dash.
The name remains updated until it is set again via a workflow or updated manually
on the Relay Dash.
 
Args:
    target (str): the device or interaction URN.
    name (str): a new name for your device.
async set_timer(self, name: str, timer_type: str = 'timeout', timeout: int = 60, timeout_type: str = 'secs')
Serves as a named timer that can be either interval or timeout.  Allows you to specify
the unit of time.
 
Args:
    name (str): a name for your timer.
    timer_type (str, optional): can be 'timeout' or 'interval'. Defaults to 'timeout'.
    timeout (int): an integer representing when you would like your timer to fire.
    timeout_type (str, optional): can be 'ms', 'secs', 'mins' or 'hrs'. Defaults to 'secs'.
async set_user_profile(self, target: str, username: str, force: bool = False)
Sets the profile of a user by updating the username.
 
Args:
    target (str): the device URN whose profile you would like to update.
    username (str): the updated username for the device.
    force (bool, optional): whether you would like to force this update. Defaults to False.
async set_var(self, name: str, value: str)
Sets a variable with the corresponding name and value. Scope of
the variable is from start to end of a workflow.  Note that you 
can only set values of type string.
Args:
    name (str): name of the variable to be created.
    value (str): value that the variable will hold.
async sms(self, stype: str, text: str, uri: str)
async start_interaction(self, target, name: str, options=None)
Starts an interaction with the user.  Triggers an INTERACTION_STARTED event
and allows the user to interact with the device via functions that require an 
interaction URN.
 
Args:
    target (target): the device that you would like to start an interaction with.
    name (str): a name for your interaction.
    options (optional): can be color, home channel, or input types. Defaults to None.
async start_timer(self, timeout: int = 60)
Starts an unnamed timer, meaning this will be the only timer on your device.
The timer will fire when it reaches the value of the 'timeout' parameter.
 
Args:
    timeout (int): the number of seconds you would like to wait until the timer fires.
async stop_playback(self, target, pb_id: str = None)
async stop_timer(self)
Stops an unnamed timer.
async switch_all_led_off(self, target)
Switches all the LEDs on a device off.
 
Args:
    target (str): the interaction URN.
async switch_all_led_on(self, target, color: str = '0000ff')
Switches all the LEDs on a device on to a specified color.
 
Args:
    target (str): the interaction URN.
    color (str, optional): the hex color code you would like the LEDs to be. Defaults to '0000ff'.
async switch_led_on(self, target, index: int, color: str = '0000ff')
Switches on an LED at a particular index to a specified color.
 
Args:
    target (str): the interaction URN.
    index (int): the index of an LED, numbered 1-12.
    color (str, optional): the hex color code you would like to turn the LED to. Defaults to '0000ff'.
async terminate(self)
Terminates a workflow.  This method is usually called
after your workflow has completed, and you would like to end the
workflow by calling end_interaction(), where you can then terminate
the workflow.
async translate(self, text: str, from_lang: str = 'en-US', to_lang: str = 'es-ES')
Translates text from one language to another.
 
Args:
    text (str): the text that you would like to translate.
    from_lang (str): the language that you would like to translate from.
    to_lang (str): the language that you would like to translate to.
 
Returns:
    str: the translated text.
async unset_var(self, name: str)
Unsets the value of a variable.  
 
Args:
    name (str): the name of the variable whose value you would like to unset.
async vibrate(self, target, pattern: list = None)
Makes the device vibrate in a particular pattern.  You can specify
how many vibrations you would like, the duration of each vibration in
milliseconds, and how long you would like the pauses between each vibration to last
in milliseconds.
 
Args:
    target (str): the interaction URN.
    pattern (list, optional): an array representing the pattern of your vibration. Defaults to None.

Static methods defined here:
get_source_uri_from_trigger(trigger: dict) -> str
Get the source URN from a workflow trigger
 
Args:
    trigger (dict): workflow trigger.
 
Raises:
    WorkflowException: thrown if the trigger param is not a dictionary.
    WorkflowException: thrown if the trigger param is not a trigger dictionary.
    WorkflowException: thrown if there is no source_uri definition in the trigger.
 
Returns:
    the source URN as a string from the trigger.
interaction_options(color: str = '0000ff', input_types: list = None, home_channel: str = 'suspend')
Options for when an interaction is started via a workflow.
 
Args:
    color (str, optional): desired color of LEDs when an interaction is started. Defaults to "0000ff".
    input_types (list, optional): input types you would like for the interaction. Defaults to an empty list.
    home_channel (str, optional): home channel for the device during the interaction. Defaults to "suspend".
 
Returns:
    the options specified.
led_info(rotations: int = None, count: int = None, duration: int = None, repeat_delay: int = None, pattern_repeats=None, colors=None)
Sets information on a device, such as the number of rotations, count, duration, repeat delay,
pattern repeats, and colors.
 
Args:
    rotations (int, optional): number of rotations. Defaults to None.
    count (int, optional): the number of times the LEDs will perform an action. Defaults to None.
    duration (int, optional): duration of the LED action in milliseconds. Defaults to None.
    repeat_delay (int, optional): the length of delay in milliseconds. Defaults to None.
    pattern_repeats (_type_, optional): the number of times a pattern should repeat. Defaults to None.
    colors (_type_, optional): hex-code of the color for the LEDs. Defaults to None.
 
Returns:
    information field that was set on the LEDs.
make_target_uris(trigger: dict)
Creates a target URN after receiving a workflow trigger.
 
Args:
    trigger (dict): workflow trigger.
 
Raises:
    WorkflowException: thrown if the trigger param is not a dictionary.
    WorkflowException: thrown if the trigger param is not a trigger dictionary.
    WorkflowException: thrown if there is no source_uri definition in the trigger.
 
Returns:
    a target object created from the trigger.
push_options(priority: str = 'normal', title: str = None, body: str = None, sound: str = 'default')
Push options for a virtual device after receiving a notification on the Relay App.
 
Args:
    priority (str, optional): priority of the notification. Can be 'normal', 'high', or 'critical'.
     Defaults to 'normal'.
    title (str, optional): title of the notification. Defaults to None.
    body (str, optional): body of the notification. Defaults to None.
    sound (str, optional): sound to be played when notification appears on app. Can be 'default', or 'sos'.
      Defaults to 'default'.
 
Returns:
    the options for priority and sound as specified.
targets_from_source_uri(source_uri: str)
Creates a target object from a source URN.
Enables the device to perform the desired action after the function
has been called.  Used interanlly by interaction functions such as
say(), listen(), vibration(), etc.
 
Args:
    source_uri (str): source uri that will be used to create a target.
 
Returns:
    the target that was created from a source URN.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Server(builtins.object)
    Server(host: str, port: int, **kwargs)
 
A websocket server that gets connected to when a new workflow
is instantiated via a trigger.
 
Events are sent here, and the connection is also used to send actions to the Relay server.
 
  Methods defined here:
__init__(self, host: str, port: int, **kwargs)
Args:
    host: the IP address of the interface that this server should
     listen on. Typically is "0.0.0.0", which represents all interfaces.
    port: the port number that this server should listen on.
    **kwargs: see below
 
Keyword Args:
    log_level: sets the threshold level for the logger in this module.
    log_handler: a log handler object to be added to the logger in this
     module. To disable logging output, use `logging.NullHandler()`.
    ssl_key_filename: if an SSLContext is desired for this server,
     this is the filename where the key in PEM format can be found.
     Should also use ssl_cert_filename if this is specified.
    ssl_cert_filename: if an SSLContext is desired for this server,
     this is the filename where the certificate in PEM format can
     be found. Should also use ssl_key_filename if this is specified.
register(self, workflow, path: str)
start(self)
total_connections(self)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class ServerException(builtins.Exception)
    ServerException(message)
 

 
 
Method resolution order:
ServerException
builtins.Exception
builtins.BaseException
builtins.object

Methods defined here:
__init__(self, message)
Initialize self.  See help(type(self)) for accurate signature.

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Static methods inherited from builtins.Exception:
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from builtins.BaseException:
__delattr__(self, name, /)
Implement delattr(self, name).
__getattribute__(self, name, /)
Return getattr(self, name).
__reduce__(...)
Helper for pickle.
__repr__(self, /)
Return repr(self).
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
__setstate__(...)
__str__(self, /)
Return str(self).
add_note(...)
Exception.add_note(note) --
add a note to the exception
with_traceback(...)
Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.

Data descriptors inherited from builtins.BaseException:
__cause__
exception cause
__context__
exception context
__dict__
__suppress_context__
__traceback__
args

 
class Workflow(builtins.object)
    Workflow(name: str)
 

 
  Methods defined here:
__init__(self, name: str)
Initialize self.  See help(type(self)) for accurate signature.
get_handler(self, event: dict)
on_button(self, _func=None, *, button='*', taps='*')
A decorator for a handler method for the BUTTON event (the Talk button was pressed).
 
async def button_handler(workflow:relay.workflow.Workflow, button:str, taps:str, source_uri:str)
on_call_connected(self, func)
A decorator for a handler method for the CALL_CONNECTED event.
A call attempt that was ringing, progressing, or incoming is now fully
connected. This event can occur on both the caller and the callee.
 
async def call_connected_handler(workflow:relay.workflow.Workflow, call_id:str, direction:str,
                                 other_device_id:str, other_device_name:str,
                                 uri:str, onnet:bool,
                                 start_time_epoch:int, connect_time_epoch:int)
on_call_disconnected(self, func)
A decorator for a handler method for the CALL_DISCONNECTED event.
A call that was once connected has become disconnected. This event can
occur on both the caller and the callee.
 
async def call_disconnected_handler(workflow:relay.workflow.Workflow, call_id:str, direction:str,
                                    other_device_id:str, other_device_name:str,
                                    uri:str, onnet:bool, reason:str,
                                    start_time_epoch:int, connect_time_epoch:int, end_time_epoch:int)
on_call_failed(self, func)
A decorator for a handler method for the CALL_FAILED event.
A call failed to get connected. This event can occur on both the caller
and the callee.
 
async def call_failed_handler(workflow:relay.workflow.Workflow, call_id:str, direction:str,
                              other_device_id:str, other_device_name:str,
                              uri:str, onnet:bool, reason:str,
                              start_time_epoch:int, connect_time_epoch:int, end_time_epoch:int)
on_call_progressing(self, func)
A decorator for a handler method for the CALL_PROGRESSING event.
The device we called is making progress on getting connected. This may
be interspersed with on_call_ringing. This event can occur on the caller.
 
async def call_progressing_handler(workflow:relay.workflow.Workflow, call_id:str, direction:str,
                                   other_device_id:str, other_device_name:str,
                                   uri:str, onnet:bool,
                                   start_time_epoch:int, connect_time_epoch:int)
on_call_received(self, func)
A decorator for a handler method for the CALL_RECEIVED event.
The device is receiving an inbound call request. This event can occur
on the callee.
 
async def call_received_handler(workflow:relay.workflow.Workflow, call_id:str, direction:str,
                                other_device_id:str, other_device_name:str,
                                uri:str, onnet:bool,
                                start_time_epoch:int)
on_call_ringing(self, func)
A decorator for a handler method for the CALL_RINGING event.
The device we called is ringing. We are waiting for them to answer.
This event can occur on the caller.
 
async def call_ringing_handler(workflow:relay.workflow.Workflow, call_id:str, direction:str,
                               other_device_id:str, other_device_name:str,
                               uri:str, onnet:bool,
                               start_time_epoch:int)
on_call_start_request(self, func)
A decorator for a handler method for the CALL_START_REQUEST event.
There is a request to make an outbound call. This event can occur on
the caller after using the "Call X" voice command on the Assistant.
 
async def call_start_request_handler(workflow:relay.workflow.Workflow, destination_uri:str)
on_incident(self, func)
A decorator for a handler method for the INCIDENT event (an incident has been created).
 
async def incident_handler(workflow:relay.workflow.Workflow, type:str, incident_id:str, reason:str)
on_interaction_lifecycle(self, func)
A decorator for a handler method for the INTERACTION_LIFECYCLE event (an interaction
is starting, resuming, or ending).
 
async def interaction_lifecycle_handler(workflow:relay.workflow.Workflow, itype:str, source_uri:str, reason:str)
on_notification(self, _func=None, *, name='*', event='*')
A decorator for a handler method for the NOTIFICATION event (a broadcast or alert was sent).
 
async def button_handler(workflow:relay.workflow.Workflow, button:str, taps:str, source_uri:str)
on_play_inbox_message(self, func)
A decorator for a handler method for the PLAY_INBOX_MESSAGE event (a missed message
is being played).
 
async def play_inbox_message_handler(workflow:relay.workflow.Workflow, action:str)
on_progress(self, func)
A decorator for a handler method for the PROGRESS event (a long running action is being
performed across a large number of devices, may get called multiple times).
 
async def progress_handler(workflow:relay.workflow.Workflow)
on_prompt(self, func)
A decorator for a handler method for the PROMPT event (text-to-speech is streaming in).
 
async def prompt_handler(workflow:relay.workflow.Workflow, source_uri:str, prompt_type:str)
on_resume(self, func)
A decorator for a handler method for the RESUME event (TBD).
 
async def resume_handler(workflow:relay.workflow.Workflow, trigger:dict)
on_sms(self, func)
A decorator for a handler method for the SMS event (TBD).
 
async def sms_handler(workflow:relay.workflow.Workflow, id:str, event:dict)
on_speech(self, func)
A decorator for a handler method for the SPEECH event (the listen() function is running).
 
async def speech_handler(workflow:relay.workflow.Workflow, transcribed_text:str, audio:bytes, language:str,
                         request_id:str, source_uri:str)
on_start(self, func)
A decorator for a handler method for the START event (workflow is starting).
 
async def start_handler(workflow:relay.workflow.Workflow, trigger:dict)
on_stop(self, func)
A decorator for a handler method for the STOP event (workflow is stopping).
 
async def stop_handler(workflow:relay.workflow.Workflow, reason:str)
on_timer(self, func)
A decorator for a handler method for the TIMER event (the unnamed timer fired).
 
async def timer_handler(workflow:relay.workflow.Workflow)
on_timer_fired(self, func)
A decorator for a handler method for the TIMER_FIRED event (a named timer fired).
 
async def timer_fired_handler(workflow:relay.workflow.Workflow, timer_name:str)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class WorkflowException(builtins.Exception)
    WorkflowException(message: str)
 

 
 
Method resolution order:
WorkflowException
builtins.Exception
builtins.BaseException
builtins.object

Methods defined here:
__init__(self, message: str)
Initialize self.  See help(type(self)) for accurate signature.

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Static methods inherited from builtins.Exception:
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.

Methods inherited from builtins.BaseException:
__delattr__(self, name, /)
Implement delattr(self, name).
__getattribute__(self, name, /)
Return getattr(self, name).
__reduce__(...)
Helper for pickle.
__repr__(self, /)
Return repr(self).
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
__setstate__(...)
__str__(self, /)
Return str(self).
add_note(...)
Exception.add_note(note) --
add a note to the exception
with_traceback(...)
Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.

Data descriptors inherited from builtins.BaseException:
__cause__
exception cause
__context__
exception context
__dict__
__suppress_context__
__traceback__
args

 
Functions
       
device_id(gid: str)
Creates a URN from a device ID.
 
Args:
    gid (str): the ID of the device.
 
Returns:
    str: the newly constructed URN.
device_name(name: str)
Creates a URN from a device name.
 
Args:
    name (str): the name of the device.
 
Returns:
    str: the newly constructed URN.
fetch_device(access_token: str, refresh_token: str, client_id: str, subscriber_id: str, user_id: str)
A convenience method for getting all the details of a device.
 
This will return quite a bit of data regarding device configuration and
state. The result, if the query was successful, should have a large JSON
dictionary.
 
Args:
    access_token(str): the current access token. Can be a placeholder value
    and this method will generate a new one and return it. If the
    original value of the access token passed in here has expired,
    this method will also generate a new one and return it.
 
    refresh_token(str): the permanent refresh_token that can be used to
    obtain a new access_token. The caller should treat the refresh
    token as very sensitive data, and secure it appropriately.
 
    client_id(str): the auth_sdk_id as returned from "relay env".
 
    subscriber_id(str): the subcriber UUID as returned from "relay whoami".
 
    user_id(str): the IMEI of the target device, such as 990007560023456.
group_id(gid: str)
Creates a URN from a group ID.
 
Args:
    gid (str): the ID of the group.
 
Returns:
    str: the newly constructed URN.
group_member(group: str, device: str)
Creates a URN for a group member.
 
Args:
    group (str): the name of the group that the device belongs to.
    device (str): the device ID or name.
 
Returns:
    str: the newly constructed URN.
group_name(name: str)
Creates a URN from a group name.
 
Args:
    name (str): the name of the group.
 
Returns:
    str: the newly constructed URN.
interaction_name(name: str) -> str
Creates a URN from an interaction name.
 
Args:
    name (str): the name of the interaction
 
Returns:
    str: the newly constructed URN.
is_interaction_uri(uri: str)
Checks if the URN is for an interaction.
 
Args:
    uri (str): the device URN.
 
Returns:
    bool: true if the URN is an interaction URN, false otherwise.
is_relay_uri(uri: str)
Checks if the URN is a Relay URN.
 
Args:
    uri (str): the device, group, or interaction URN.
 
Returns:
    bool: true if the URN is a Relay URN, false otherwise.
parse_device_id(uri: str)
Parses out a device ID from a device or interaction URN.
 
Args:
    uri (str): the device or interaction URN that you would like to extract the device ID from.
 
Returns:
    str: the device ID.
parse_device_name(uri: str)
Parses out a device name from a device or interaction URN.
 
Args:
    uri (str): the device or interaction URN that you would like to extract the device name from.
 
Returns:
    str: the device name.
parse_group_id(uri: str)
Parses out a group ID from a group URN. 
 
Args:
    uri (str): the URN that you would like to extract the group ID from.
 
Returns:
    str: the group ID.
parse_group_name(uri: str)
Parses out a group name from a group URN.
 
Args:
    uri (str): the URN that you would like to extract the group name from.
 
Returns:
    str: the group name.
parse_interaction(uri: str)
Parses out the name of an interaction from an interaction URN.
 
Args:
    uri (str): the interaction URN that you would like to parse the interaction from.
 
Returns:
    str: the name of an interaction.
remove_null(obj)
trigger_workflow(access_token: str, refresh_token: str, client_id: str, workflow_id: str, subscriber_id: str, user_id: str, targets: List[str], action_args: dict = None)
A convenience method for sending an HTTP trigger to the Relay server.
 
This generally would be used in a third-party system to start a Relay
workflow via an HTTP trigger and optionally pass data to it with
action_args.  Under the covers, this uses Python's "request" library
for using the https protocol.
 
If the access_token has expired and the request gets a 401 response,
a new access_token will be automatically generated via the refresh_token,
and the request will be resubmitted with the new access_token. Otherwise
the refresh token won't be used.
 
This method will return a tuple of (requests.Response, access_token)
where you can inspect the http response, and get the updated access_token
if it was updated (otherwise the original access_token will be returned).
 
Args:
    access_token(str): the current access token. Can be a placeholder value
    and this method will generate a new one and return it. If the
    original value of the access token passed in here has expired,
    this method will also generate a new one and return it.
 
    refresh_token(str): the permanent refresh_token that can be used to
    obtain a new access_token. The caller should treat the refresh
    token as very sensitive data, and secure it appropriately.
 
    client_id(str): the auth_sdk_id as returned from "relay env".
 
    workflow_id(str): the workflow_id as returned from "relay workflow list".
    Usually starts with "wf_".
 
    subscriber_id(str): the subcriber UUID as returned from "relay whoami".
 
    user_id(str): the IMEI of the target device, such as 990007560023456.
 
    targets: the device targets that the workflow should be considered as
    having been triggered from.
 
    action_args (optional): a dict of any key/value arguments you want
    to pass in to the workflow that gets started by this trigger.

 
Data
        AUTH_HOSTNAME = 'auth.relaygo.com'
DEVICE = 'device'
DEVICE_PATTERN = '?device='
GROUP = 'group'
ID = 'id'
INTERACTION = 'interaction'
INTERACTION_URI_ID = 'urn:relay-resource:id:interaction'
INTERACTION_URI_NAME = 'urn:relay-resource:name:interaction'
List = typing.List
NAME = 'name'
Optional = typing.Optional
ROOT = 'relay-resource'
SCHEME = 'urn'
SERVER_HOSTNAME = 'all-main-pro-ibot.relaysvr.com'
TYPE_ENDED = 'ended'
TYPE_STARTED = 'started'
Union = typing.Union
VERSION = 'relay-sdk-python/2.0.0-alpha'
logger = <Logger workflow (WARNING)>