Keeping some state within a single session of Alexa skill could play an important role of how the skill interacts with a user.
Keeping the state between sessions may bring your skill to another level.
By doing so, the skill can pick up the user from the middle of a conversation and proceed from there.
Sounds great? So let’s learn how we can achieve that.
Last time we have learned how to capture input from the user.
Using captured inputs we are able to handle communication with users from our skills.
But a skill does not always have a linear conversation.
We may want to ask a question and behave differently based on the answer we’ve got.
To do that, we need to keep some information in the “memory” of an Alexa skill.
To achieve that, Alexa Skill SDK provides us an ability to use Session Attributes.
Let’s see how we can use that.
In the previous articles we have built a Hello World Alexa skill.
As any other hello world programs, the skill does only one job.
We can only ask a single question and receive the single answer back.
Although you can build skill using that kind of interaction with a user, sooner or later you will feel the need of getting some custom data from a user.
For example, you may want to tell a number or a name of a city and behave differently based on the answer.
Let’s see how we can do that.
Today, I need to parse a string of a specific format and grab a couple of values from the string using Swift programming language.
Sounds like a trivial problem. All I need to do is to use a regular expression to find the information I need.
That post would not have written unless I had encountered a couple of difficulties.
I have to admit that I am relatively new to Swift and some parts of the language are not that obvious to me and probably for some beginners.
Yet another issue I’ve faced today is the Swift documentation.
The documentation looks incomplete.
Although, I might have a bad luck using documentation related to regular expressions.
Anyway. Let’s jump ahead and see how I’ve solved that issue.
I hope that solution can help someone as well.
In the previous article we have created our first Alexa skill.
We have implemented all the steps manually.
We have created a skill from the web interface.
We have configured the interaction model.
Then we have created a lambda function with the simplest implementation of the skill.
And then we have linked the lambda function and the skill together, so they can work as a one.
All of these steps can be optimized and improved.
That’s why this time I would like to cover a way to create an Alexa skill using a command line and a code editor of your choice.
Although we would need to use AWS web interface to create a user and policy, the rest would be done via command line interface.
Let’s get started.