Dynamic Parameters Examples


With dynamic parameters, you can use custom triggers and parameters that aren't predefined in the trigger definition file. Instead these parameters are returned through the interfaces that your skill supports. One common use case is to use dynamic parameters to show options that are specific to a customer.

The following examples use dynamic parameters to send triggers in a routines skill.

Trigger for battery low alerts

The following example shows how to set the radio battery low as a custom trigger. In the example, the fictitious radio is named MyRadioPlayer. Because this trigger requires that you specify the device for which a trigger instance should be published when the battery is low, this trigger needs to use dynamic parameters.

Trigger definition

The following example shows the trigger definition for MyRadioPlayerBatteryLow.

Routines.TriggerParameter.Get Service Provider Interface (SPI) handler

The endpoint in the skill manifest for a UNICAST skill for handling Routines.Trigger.Create and Routines.Trigger.Delete requests must also be able to handle Routines.TriggerParameter.Get requests.

For this trigger, the custom triggers platform sends the following request to retrieve the possible values for the MyRadioPlayer device ID.

You send the following response.

Routines.Trigger.Create SPI callback

When the customer saves a routine with your trigger with dynamic parameters, you should expect the parameters in the SPI callback to contain those dynamic values. For example,

Trigger instance publishing

After the customer saves the routine, you send trigger instances with parameter values that match what was in the Routines.Trigger.Create SPI callback. The following example shows instances with values that match what was in the Routines.Trigger.Create SPI callback.

Trigger for maintenance reminders

The following example shows how to set a maintenance reminder as a custom trigger. Because this trigger requires that you specify the device for which a trigger instance should be published and has a second parameter for the maintenance type, which is dependent on the device, this trigger needs to use dynamic parameters.

Trigger definition

The following example shows the trigger definition for MyRadioPlayerMaintenanceReminder.

Routines.TriggerParameter.Get SPI handler

The endpoint in the skill manifest for a UNICAST skill for handling Routines.Trigger.Create and Routines.Trigger.Delete requests must also be able to handle Routines.TriggerParameter.Get requests.

For this trigger, the custom triggers platform sends two requests: one for getting the possible DeviceId for the device, the other for getting the possible maintenance reminder options for the device selected by the customer.

1. The following example shows the request to retrieve possible values for the MyRadioPlayerDeviceId.

You send the following response:

2. The following example shows the request to retrieve the possible values for the maintenanceReminderType based on the customer’s selection for amzn1.alexa.endpoint.uniqueMyRadioPlayerId2.

You send the following response.

Trigger for charging status changed alerts

The following example shows how to set a charging status changed as a custom trigger. Because this trigger requires that you specify the device for which the trigger instance should be published, this trigger needs to use dynamic parameters. The second parameter chargingStatus is a static enum parameter to indicate the available charging statuses.

Trigger definition

The following example show the trigger definition for MyRadioPlayerChargingStatusChanged.

Routines.TriggerParameter.Get SPI handler

The endpoint in the skill manifest for a UNICAST skill for handling Routines.Trigger.Create and Routines.Trigger.Delete requests must also be able to handle Routines.TriggerParameter.Get requests.

For this trigger, the custom triggers platform sends the following request to retrieve possible values for the MyRadioPlayerDeviceId. For the chargingStatus field, it is a static enum whose possible values are the same so no request is needed.

You send the following response.

Trigger for posting weather messages

The following example shows how to set up a mechanism to post weather messages. You can set up triggers based on specific conditions on messages, but not all conditions are available to all users. Some are exclusive to users with the premium subscription only. Because this trigger must dynamically restrict the options available based on the user's subscription, this trigger needs to use dynamic parameters.

Trigger definition

The following example shows the trigger definition for MyWeatherMessagePosted.

Routines.TriggerParameter.Get SPI handler

The endpoint in the skill manifest for a UNICAST skill for handling Routines.Trigger.Create and Routines.Trigger.Delete requests must also be able to handle Routines.TriggerParameter.Get requests.

For this trigger, the custom triggers platform sends the following request to retrieve the values that the customer should have access to based on whether they have the MyWeather subscription.

You send the following response for a customer with the premium subscription for MyWeather.

You send the following response for a customer who doesn't subscribe to MyWeather.


Was this page helpful?

Last updated: Nov 27, 2023