I am trying to implement BDD test on my Alexa skill. I am using Java SDK to implement it.
Basically, I would like to trigger arbitrary intents programmatically in my test suite and assert on responses, but I could not find any materials to implement it.
All I could find is com.amazon.ask.model.services.skillMessaging.SkillMessagingServiceClient.sendSkillMessage
, whose Javadoc says:
Send a message request to a skill for a specified user.
That would be what I need, but, in order to create a com.amazon.ask.model.services.skillMessaging.SkillMessagingServiceClient
, I have to do the following:
SkillMessagingServiceClient client = new SkillMessagingServiceClient(
DefaultApiConfiguration.builder()
.withApiClient(ApacheHttpApiClient.standard())
.withSerializer(new JacksonSerializer())
.withAuthorizationValue("<authorization_token").build(),
DefaultAuthenticationConfiguration.builder()
.withClientId("<client_id>")
.withClientSecret("<client_secret>")
.build()
);
In order to get client_id
and client_secret
:
- I have accessed Login with Amazon Console
- I have created a security profile
- I have enabled Account Linking on my skill, with
- Authorization URI:
https://www.amazon.com/ap/oa
- Access token URI:
https://api.amazon.com/auth/o2/token
- Client ID and Client secret as from point 2
- Scopes:
alexa:skill_messaging
andprofile:user_id
- Authentication schema: Basic
- Authorization URI:
- I have copied all the Alexa Redirect URLs in the allowed return web URIs in my security profile
As a result, now my skill could be bound to my Amazon account from Alexa app, but:
- All in all, I just wanted to implement tests, NOT bind my account. My skill in production does not need this feature
- The binding does not work: after confirming it from Alexa app, I receive an error
- Yet I do not know how to collect the authentication token, unless I catch it from Cloudwatch log and use it... until it expires
At point 2, I could see the reason of the failure: oauthError
(https://skills-store.amazon.it/external/link-result?success=false&errorKey=oauth-error&languageCode=it_IT&skillId=amzn1.ask.skill......&skillStage=development
). The web page contains a link to RFC6749.
I am currently stuck and I can not test my skill completely, also because it is impossible to test Alexa Player, especially in Italian, unless you directly test it using a physical device.
Thanks for the help.