getRandomeMessage() provides you to get the randomized message. Let’s make your skill more engaging.
Alexa team told us to make our skill interactions more natural and conversational.
-> Alexa Skill Recipe: Randomize Your Responses to Add Variety to Your Skill
And the blog post tell us the example code to get the randomized message.
function randomPhrase(myData) {
// the argument is an array [] of words or phrases
var i = 0;
i = Math.floor(Math.random() * myData.length);
return(myData[i]);
}
const confirmations = ['ok','got it','roger that', 'sounds good', 'great'];
const message = "Here’s your random confirmation message, " + randomPhrase(confirmations))
ask-utils provides simple helper function.
The ask-utils provides a useful helper function.
The function is getRandomMessage()
.
When use the function, you don’t have to define these a helper function.
import { getRandomMessage } from 'ask-utils'
const message = "Here’s your random confirmation message, " + getRandomMessage([
'ok',
'got it',
'roger that',
'sounds good',
'great'
]
)