Creating alexa skills with .NET – part 5 Alexa Skills, a testing time.
in Part 4 we created the skeleton of the rest service we will be using as an endpoint.
.We go back now to the Alexa developer console, and if not already done we should make sure that we actually build the model, if you don’t do this you will be running with the last built settings and not your current ones.

We can now use the test menu, which for a new skill will show testing as not being available

if you can’t switch on testing then something is wrong. if you click on the ‘CUSTOM’ option near the top left of the window you get back to the checklist and it should like the one below

All being well you can switch on the testing now and test it within the developer console.

In the image below I have typed in one of my test utterances, along with ‘ask Testy McTestface’ and this simulates an alexa device and the reply

In the right hand window we see the JSON output, this is basically what our endpoint provided
{
"body": {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "PlainText",
"text": "Hi, I'm Testy McTestFace"
},
"shouldEndSession": true,
"type": "_DEFAULT_RESPONSE"
}
}
}
We can see from the above that the reply contained ‘outputSpeech’ and the text within this is the text we entered in the rest service.
Of more interest to us however is the left hand panel, the JSON input, this is what is being sent TO our rest service and so this is what we should be handling. (I have edited out some of the longer data strings for clarity)
{
"version": "1.0",
"session": {
"new": true,
"sessionId": "amzn1.echo-api.session.",
"application": {
"applicationId": "amzn1.ask.skill."
},
"user": {
"userId": "amzn1.ask.account."
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill."
},
"user": {
"userId": "amzn1.ask.account."
},
"device": {
"deviceId": "amzn1.ask.device.",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.amazonalexa.com",
"apiAccessToken": "eyJ0eXAiOiJKV1"
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
],
"video": {
"codecs": [
"H_264_42",
"H_264_41"
]
}
}
},
"request": {
"type": "IntentRequest",
"requestId": "amzn1.echo-api.request.",
"timestamp": "2019-07-20T13:51:47Z",
"locale": "en-GB",
"intent": {
"name": "IntentTalkToMe",
"confirmationStatus": "NONE"
}
}
}
The end part is the bit we will be most interested with as we develop the next stage of the rest service.
We see that the alexa system is passing us an ‘IntentRequest’ and that the intent name is ‘IntentTalkToMe’ which is the value we entered in the interaction model.
Now we can go to the distribution tab and see if we can switch on testing for a real device, the requirements for this change over time and so it is quite likely that this is not going to be allowed yet (or as some stage in the future will not be allowed).

You will need to answer all the questions on the privacy page and all the other sections that exist at the time and pertain to your skill.
At the time of writing this adding in icons, privacy notice links etc does allow beta testing to be actvated

You can now enter some email addresses for testers and then activate the testing. The tester email addresses must be the one you use for alexa registrations and may not be the same as your developer console one.

So all being well you should now have testing setup and also have access to an invite url you could share if needed.
If you use the link or click on the email your testers get you should be logged into your Alexa account and be asked to confirm you want to test the skill.


You then also have to enable the skill, note that under the icon there should always be a green bar with something like devUS in it.
You can then start speaking to one of your alexa devices, for example ‘Alexa, ask Testy McTestface to say something’ and a short while later it should say ‘Hi, I’m Testy McTestface’.
You now can test your skill on both the developer console and on a real device. if you don’t have an alexa around to test with, or you prefer to not use one then you can also use the Alexa simulator, this is found at https://echosim.io/welcome. You will need to log in using your alexa account and still have the skill activated for testing as above.

And that about wraps up the testing setup, for a skill that does not require any special access (for example to your address) this is all you need do to start testing.
In part 6 we will be going back to the rest service and adding in some additional code which would be needed to get any skill past the certification process (skills need to pass these tests before becoming available to the public).

