List in custom Alexa skills - alexa

I'm new to Alexa Skills but meanwhile I've read tons of information and tutorials.
Fortunately, I'm currently able to create my own custom skill (based on PHP) on my own server and it already works using different intents, utterances, slots etc..
Now, I want Alexa to read a list of items (I send via JSON) in PlainText but I can't find any information how to do this.
I assume there are two options (please correct me if I'm wrong):
Sending a JSON answer including one item - Alexa reads this item - the user says e.g. "next" - Alexa requests my server for the next item - my server sends the next JSON answer ... and so on.
Sending a JSON answer including all items in an array - Alexa reads each item one after another.
I'm not sure which solution is possible and how it can be solved.
So, can anyone help me on this or point me to some information?

Both ways are possible and which one to choose depends on what you are listing.
Using AMAZON.NextIntent
If a single list item include item name and some details about it, then reading out it in one go won't be a good user experience. In this case you can use AMAZON.NextIntent to handle users "next" request.
When the user asks for the list, give the first item in your response and keep a track of the item index in response sessionAttributes. You can also set a STATE attribute too, so that you can check this state in AMAZON.NextIntent handler before you give the next item.
"sessionAttributes": {
"index": 1,
"STATE": "LIST_ITEMS"
}
When the user say "next"
check whether the state is LIST_ITEMS and based on the index give the next item from your list. And in sessionAttributes increment the index
More on sessionAttributes and Response Parameters here
Now, if your items are just names then you can read it one after the other.
In both these solutions it is always good to use SSML rather than just PlainText. SSML gives you more control on how your response is spoken.
More on SSML here

Related

how to store likes data in flutter

I'm developing an app in which I need to show come "coupons" I get from the API. I also have a "liked coupons" page where I need to show the ones the user has liked. I'm facing 2 problems here:
1- I don't know how to store likes, should I implement a local database for everything or should I ask our back-end team to save the liked/not liked state on the server?
2- I have a model class for coupons, and I have a coupon_list widget which is a horizontal listview.builder(). the problem is that some coupons are being showed in 2 or 3 different lists and I need them to all turn to liked when user likes an instance from a single list. how can I do that? (I want to do something like working with pointers in c++, passing the ACTUAL variable instead of it's value so it changes globally)
I would like to suggest you to store it in server as well. (Ask to your back-end team to add parameter) So that if user logout or sign in from different device "liked coupons" data will be available in all cases.
And for 2) multiple coupon entry you have to manage it via unique id. Like every coupon has its unique series no / pattern num. So you can put condition on that. i.e. Add "unique_no" to liked_list from all available list of coupon
Solution
Use Shared Preferences! This is something like a database on the device you are currently running. So if the user makes a like you can save that on their device!
To add Shared Preferences to your app look this video
Hope it helps!

Salesforce Screen flow search and display record information

I'm working on a screen flow. The idea is to have a lookup component the user can search a contact. Then I would like to display the information from the Contact (Account Name, Contact Name, Number Email) and I would like to be able to have the user update that information if needed. I just stomped on how it can be done. I know it should be able to be pulled from the record ID in some type of way and maybe use an Assignment to display the information. Can someone guide me on a next step or if anyone has an instructional video would be helpful.
Thanks
You wouldn't be able to display the looked up contact's fields on that screen as soon as you populate that field. That would be something only possible in code (aura component or lwc).
What you can do, however is -
Get Record element after that screen element. (Get Contact, where Id = lookupcomponent.recordId)
Then EITHER:
use the new Fields (BETA) option on another screen Fields (BETA)
(this method is easier, doesn't have as much control and is limited on fields, depending on data type, you can use)
add inputs one by one and set the default values Add Fields One By One
(this method allows more control)
Then, you will need an update element. If you used the Fields (BETA) you can just update the record variable. If you did the inputs one by one, you will need to update the contact and set fields individually.
Full Flow Example

Only 2 steps are different when compared to two feature files. (cucumber-selenium-java)

I am learning cucumber. I have two scenarios. I can't say the exact due to company policies. First Step file is like
Scenario 1: Flow with attachments
Given Login to APP
When User chooses "country"
And clicks "Yes"
And attaches "files"
And Go to location page
And add comments
Then Submit
Scenario2: Flow without attachments
Given Login to APP
When User chooses "country"
And clicks "Yes"
And add players manually
And User picks players
And User clicks on a player
And does the settings
And Go to location page
And add comments
Then Submit
Do I need to write all the steps again in Scenario 2 or can I do something so that I can bypass writing all the steps in feature file.
I mean can I maintain only different steps in the 2nd feature while like we do in writing step file or glue code for that.
If yes how to do it, so that it run all the previous steps. Please help
Instead of writing all the steps in terms of small actions the users performs on the system (like "go to page", "click this" , "submit that"), think about what the user is trying to achieve and create a step that describes that in a way that is meaningful to the user (i.e. "add players from a file", or "add players manually"). The step definition for that step will then contain all of these actions on the system (click this, fill that, etc). You can also use what we call "helper methods" from your step definition; for example create a method that will navigate to a certain page, and call that method with the relevant page to go to from your various step definitions.
That way your scenarios will describe the intended behaviour of the system, or what the user is supposed to be allowed to do (or not do).
Also, from the examples you've provided it is not clear to me what it is you are testing/asserting. I've always found it helpful to use "Given/And" to set up the original state of the system, "When/And" for the actions to be performed that you want to test the outcome of, and "Then/And" to verify the expected result.
The title of the scenario should clearly describe what it is the scenario tests for.
From your example, I've assumed that you are testing that a user is able to add players either from a file or manually. In that case, the scenarios could look something like the following:
Scenario: User is able to add players from a file
Given a user who is logged in
And the user has selected "country"
When the user attaches "files"
And adds a comment about location
Then the players are added
And the comment is saved
Scenario: user is able to add players manually
Given a user who is logged in
And the user has selected "country"
When the user adds players manually
And adds a comment about location
Then the players are added
And the comment is saved
In the example above, I am also assuming that the following steps:
And add players manually
And User picks players
And User clicks on a player
And does the settings
are actually all (always) needed to add players manually, so all of those actions would be performed in the one step "And add players manually" (either by implementing them all in one step, or calling several helper methods from that one step).
By describing the behaviour like this it is much clearer what you are testing in each scenario and what the expected behaviour of the system is.
Also, it will lead to way less duplication of "steps" (as was your original question, I believe).

How to get the number (length) of slot values for Alexa skill

I am trying to generate a random response for my Alexa Skill. I have set it up as:
Intent = myIntent
Slot = mySlot
Slot Type = mySlotType
Slot Values = {A,B,C,D} //the ids are unique numbers 1 - 4
when the user says a word such as A it uses this to create a response. Now I want to add a case for 'random'.
So Slot Values = {random,A,B,C,D}. //ID for random is 0
When the user says random, I want to randomly choose from the other Slot Values and use this to create a response.
Can Slot Value ID be used to return the Slot Value value?
Anybody know a good way to do this? I am a novice so excuse any obvious oversights.
This might be a workaround for your problem. You can get the JSON structure of your interaction model and use it as a constant in your lambda index.js file. I usually use this official tool for generating backend code for my skill
:
https://s3.amazonaws.com/webappvui/skillcode/v2/index.html.
When you'll generate the code through this tool, you'll see that the code generated also has the whole interaction model used as constant. Since you will have the whole JSON schema of the interaction model at your disposal, you can perform any action on it.
Note: If you don't know where to get JSON schema of your interaction model, scroll down on the build tab of your skill on the developer console, you'll find a menu of JSON editor on the left navigation. It will give you the JSON schema of your interaction model.
You can use mySlot as optional value in the intent description. For example you can add few utterances without slot inside them. And on the backend side you can check is the slot filled. If it is not filled you can generate random answer.

Using sessionAttributes in Alexa Skill

I am building an Alexa skill and not quite sure if I am using sessionAtrributes correctly. I know sessionAttributes are used to carry-forward a session's data to next invocation.
So I have these two intents
1) ListToDoItem
In this intent my skill will look into a database and list out the
to-do items stored in the database. After listing the items, Alexa
will go on to say "do you want me to list detailed info on these
to-do items?", to handle this I will pass the items retrieved in the
previous session as sessionAttributes. When asked to list detailed
info on the items, I will extract the previously forwarded
sessionAtrributes and compose a detailed speech response.
So for this intent I have to sample utterances
list my to-do items
yes
The utterance 'yes' will be used so that the sessionAttributes can be extracted to create a detailed speech response.
2) ListDoneItems
This intent will be used to list out completed items. It is similar to the previous intent, the only difference being, this intent will list out completed items.
For this intent will have 2 sample utterances
list my completed items
yes
Like before it has an 'yes' to generate a detailed speech response based on the sessionAttributes.
But the problem I have is that when I reply 'yes' to the ListDoneItems intent's 'Do you want me to list the completed items'?, the next intent request generated is of type ListToDoItems instead of ListDoneItems, even though I have set shouldEndSession to false in my skill response. This is happening because there is a crossover between sample utterances between my intents. So is having similar intents in different intents wrong? How to design interaction model to create a multi-turn dialog in order to use in sessionAttributes?
I think this will be of use to someone searching for answer.
Basically in the sample utterance you should not include phrases for your re-prompts; i.e. in my case I should not add 'yes' as an utterance. Instead I should be using Amazon.YesIntent.
When using Amazon.YesIntent, you should maintain a state machine in your SessionAttributes pointing to the last invoked intent. For example if two or more of your intents have a possible case where the user response could invoke a YesIntent, you should store the last invoked intent name and the associated session data in the SessionAttributes. So in the function which handles the YesIntent, you should check the state of your previous invocations and delegate to control to the corresponding intent handler.
In my case I will store previously invoked intent name as key and its associated data as it's value in the session.attributes;
"session": {
"new":"false",
"sessionId": "sessionId",
"application": {
"applicationId": "applicationId"
},
"attributes": {
"PreviousIntent": {
"PreviousIntentData"
}
}
In the function which handles YesIntent, check the for the previous state (session.attributes.PreviousIntent) and delegate the control to the function which handles that intent.

Resources