Response Groups allow you to specify the conditions that must be met for voice, audio, APL Templates, and other responses you put in the group are sent to the user.
This simple concept allows you to build logic into your voice application.
Let's see how it works..
Using Response Groups
As you might guess, Response Groups can be found on the Responses tab in the Block Configuration tool.
When you create a new Block, a single Response Group with a single Voice Response function is created for you.
The outer card is the Response Group. The inner card is the Voice Response. You can add as many responses to the group as you need.
You can use the icons at the bottom of the Response Group to add additional responses to the group.
You can hover over each icon to see a description of what it does. In order from left to right, they are Voice Response, Short Audio, Home Cards, Permissions, Display Templates, and APL Templates.
- Voice Response - Speaks the text you enter using the selected voice
- Short Audio - Plays a short audio file
- Home Cards - Allows you to send informational cards to the user's Alexa App
- Permissions - Allows you to ask the user for permissions to access user information and advanced features
- Display Templates - Sends a simple formatted display to voice devices that also have a screen.
- APL Templates - Sends templates create using the Alexa Presentation Language to devices with screens.
You can delete a response from a Response Group by clicking the trash can icon in the upper-right corner of the response card.
Changing Response Order
You can change the order of the responses within a Response Group by dragging one response above or below the other.
Adding Response Groups
You can add additional Response Groups to the Block by clicking the New Response Group icon at the very bottom of the Response tab.
Changing Response Group Order
When you have multiple Response Groups, you can change the order of the Response Groups themselves. Again, you do this by simply dragging one Response Group above or below the other.
Controlling When Response Groups Give A Response
The real power of Response Groups is the ability to define under what conditions the Response Group responses will actually be given.
At the bottom of each Response Group, you'll see a When setting.
By default it is set to "Always" meaning the Response Group will always send its responses to the user.
If you click on the "Always" link, it will open up an Expression Editor so you can specify the conditions under which this Response Group should give its output.
As an example, suppose we want to send the user a request to leave a 5-star review for our voice application. We don't annoy the user with this request every time they use our skill. We only want to ask them on, say, the 5th visit. We would configure the When condition of our Response Group like this:
This means that this Response Group (and all of the responses we put in it) will only be sent to the user on their 5th visit to our application.... when visitCount = 5.
Note: visitCount is one of the many built-in variables that we can use in our voice application. Click here to learn more about variables.
Imagine, for this example, that our voice application is a two player game and we want to give one response if the user wins and another response if the other player won. We could configure two Response Groups.... one with the winning responses and the other with the losing responses and use our When condition to determine when each should execute.
Response Group 1:
Response Group 2: