I'm doing utterance and other automated testing in my build/deploy flow for my Alexa skill. Now I also want to use the simulate API (https://developer.amazon.com/en-US/docs/alexa/smapi/skill-simulation-api.html) to do entire conversational flows but I get stuck immediately. My skill uses account linking so somehow I need to pass along credentials for a user. In the documentation I can't see any way to pass along any other arguments than the session id, locale and utterance. Should I somehow use the LWA profile to sign in to my service and in that case, how would I do that (since it's only client id and client secret, no email/password)?
This is how I have setup the javascript code for my LWA profile (that works for all requests besides the simulate API and invocation API).
const ASK = require("ask-smapi-sdk");
const refreshTokenConfig = {
clientId: "amzn1.application-oa2-client.xxx",
clientSecret: "xxx",
refreshToken: "Atzr|xxx",
};
const smapiClient = new ASK.StandardSmapiClientBuilder()
.withRefreshTokenConfig(refreshTokenConfig)
.client();
If I would call this skill now using the simulate API a request/response sample would look something like this.
await smapiClient.setSkillEnablementV1(skillId, "development");
const response = await smapiClient.simulateSkillV2(skillId, "development", {
device: {
locale: "en-US",
},
input: {
content: "Alexa, ask mySkill to do something",
},
session: {
mode: "FORCE_NEW_SESSION",
},
});
response
would now contain this section in the response json.
body: {
version: "1.0",
response: {
outputSpeech: {
type: "SSML",
ssml: "<speak>Hi, to use mySkill, please go to your Alexa app and link your mySkill account.</speak>",
},
card: { type: "LinkAccount" },
shouldEndSession: true,
type: "_DEFAULT_RESPONSE",
},
sessionAttributes: {
...
},
userAgent: "ask-node/2.10.1 Node/v12.19.0",
},
},
To repeat my question, how can I sign in a user programmatically, should I use my LWA profile somehow or is there another process?
Thanks!
I have two classes made for this to make my life easier
skillsimulation:
simualtion response: