In order to send an actionable notification to the mobile app and respond to it, I needed to:
- Send a notification with actions configured using YAML in
data
. It must have a tag. - A wait for trigger action: with a trigger for the
mobile_app_notification_action
event for each possible action id - Clear the notification, by sending a new notification with the same tag and a special message string (
clear_notification
) - A Choose action for each notification action, using template conditions matching against the action keys (in the
wait.trigger.event.data.action
variable)
It would be nice if there was a new action for actionable notifications that encapsulated these four separate actions in one:
- Include a required field for the message’s tag (or just generate a unique tag for the automation run).
- Automatically wait for the
mobile_app_notification_action
, with an optional timeout, that only continues if an expected action id is received. - Clear the notification when a response is received, or the timeout is reached
- Allow a list of actions, where each is configured with a label, id, and set of actions to perform if chosen (the id could possibly be generated, to ensure it’s unique to the automation run).
- An optional default list of actions if the notification times out.