Skip to content

Instantly share code, notes, and snippets.

@ckundo
Created January 6, 2020 15:31
Show Gist options
  • Save ckundo/ee8b54cb8c7e3ccbdf3bf427faccef86 to your computer and use it in GitHub Desktop.
Save ckundo/ee8b54cb8c7e3ccbdf3bf427faccef86 to your computer and use it in GitHub Desktop.
end-to-end testing for Amazon Alexa (with display)
#!/bin/sh
# end-to-end testing for Amazon Alexa (with display)
set -e
# invoke Alexa via ask API, and print the results to stdout
speak () {
echo "User:"
echo "> $1"
id=$(ask api simulate-skill --text "$1" --locale=en-US --skill-id=<skill-id> | jq -r '.id')
res=$(ask api get-simulation -i $id -s <skill-id>)
echo "Alexa:"
echo $res | jq '.result.alexaExecutionInfo.alexaResponses[0].content.caption'
echo $res | jq '.result.skillExecutionInfo.invocations[0].invocationResponse.body.response.directives[0].template.backgroundImage.sources[0].url'
}
# Start with --force-new-session
id=$(ask api simulate-skill --text "$1" --locale=en-US --skill-id=<skill-id> | jq -r '.id')
res=$(ask api get-simulation -i $id -s <skill-id>)
echo "Alexa:"
echo $res | jq '.result.alexaExecutionInfo.alexaResponses[0].content.caption'
echo $res | jq '.result.skillExecutionInfo.invocations[0].invocationResponse.body.response.directives[0].template.backgroundImage.sources[0].url'
# Example utterances
speak 'open museum bot'
speak 'more like this'
speak 'search for Picasso'
speak 'next'
speak 'show me Warhol'
speak 'search for Andy Warhol'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment