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
:
https://www.amazon.com/ap/oa
https://api.amazon.com/auth/o2/token
alexa:skill_messaging
and profile:user_id
As a result, now my skill could be bound to my Amazon account from Alexa app, but:
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.
It seems you are confused between account linking and skill credentials. Account linking is for making api calls to external services on behalf of the user, E.G. I want my skill able to access user's google profile.
Thus for your use case, skill credentials which used to make API calls to skill-related Alexa services seems good enough. Since you already got the clientId, client secrect, I would recommend you explore the Ask-Smapi-Sdk. You could follow the readme to retrieve the refreshToken through ask-cli, and build smapi client. With SmapiClient, you could use Smapi simulate apis to trigger your intents, specially the function simulateSkillV1 defined in your smapi Client.
Hope this is what you need. ✧(•̀ω•́ )
Thanks,
Shen