Setting variables from multiple events in a single run

Wondering if the wizards here are able to push me in the right direction. I’m trying to dynamically set two values in a service call…with what I think is a twist.

Using the Alexa Actionable Notifications, I’m attempting to create a scenario where a user would be prompted for two values in sequence, and those values would then be used to set parameters for in this case an Eight Sleep Mattress.

The Alexa actionable notifications will return an event with the relevant data attached within the event.

I’m trying to wrap my head around how I would achieve this or if it’s even possible. Would I need multiple automatons and scripts or can this be done in one single run? I have the Alexa actionable notifications working great out of the box. This is really about parsing multiples events and setting multiple variables.

I believe the sequence would be:

  1. Call Service 1
  2. Wait for Trigger (Event 1)
  3. Receive Event 1
  4. Parse Event 1 event_data and set Variable 1
  5. Call Service 2
  6. Wait for Trigger (Event 2)
  7. Receive Event 2
  8. Parse Event 2 event_data and set Variable 2
  9. Call Service 3 and replace values in Service call with Variable 1 and Variable 2

I’m relatively new to variables but have been trying to research this on my own without any luck. Any help would be greatly appreciated. Thanks!

Well for anyone keeping score. I gave up on variables, a single automation and keeping this as neat as possible.

Ultimately, it ended taking 3 automations, 2 input_numbers, 1 input_button, and 1 script. + Alexa Actionable Notifications AAN (which uses another script and input_text). That’s a lot going on!

  1. I ask my Echo to turn on my mattress.
  2. This flips the input_button for My Mattress and triggers…
  3. Automation 1 calls AAN script to ask “How warm do you want it? 1-100”
  4. Automation 2 triggers off the previous event, sets the Mattress Warmth input_number based on the event_data in the response, then calls the AAN script to ask “For how many hours?”
  5. Automation 3 triggers off the previous event, sets the Mattress Duration input_number, then calls a…
  6. Script that calls the Eight Sleep service which sets the mattress to the values based on the two input_numbers, sends a confirmation to the Echo, and a push notification to my phone.

This works about 90% of the time. Every so often, Automation 3 doesn’t fire, which I think may have something to do with HA and the event system’s timeout? I added a 1 second delay in Automation 2 prior to calling the second AAN script and I seem to be getting a better batting average.