I was hoping to create an intent that only makes a statement to the user. I was thinking I could do this by having some utterances that trigger the intent with no slots, but with a "goodbye message". When I try to do that, when I save the intent, it deletes the goodbye message and reverts it to None. I also picked a "no-op" lambda function to call since it doesn't make sense for what I'm doing.
At this point, I'm not sure about how to do this, but it seems like the claudia-bot-builder has support for something like this, but I can't get it to deploy to my AWS account to see how it might do it.
Does anyone else here have an idea about how to have the bot just give information in response to an utterance instead of starting a dialog to retrieve information?
You can return simple messages to the user using only Amazon Lex Console without any Lambda Function selected.
Open your Lex Chat Bot in console.aws.amazon.com/lex/home....
1 Click the "Editor" Tab.
2 On the left, click on the Intent you want to return a message on.
3 On the right, scroll down to the "Fulfillment" section.
4 Click "Return parameters to client"
5 In "Response" section, type in the message(s) you want to respond with.
Note: Make sure the section "Lambda initialization and validation" is unchecked so that the intent goes directly to the "Fulfillment" response.
Related
This is a bit of a silly question but I wasn't able to find anything in the documentation or a spot to change it in the Amazon Lex console.
In Lex V1, there was a tab in the editor called 'Error Handling' where you could clearly change the messages for the clarification prompt and hang-up phrase.
I started working with Lex V2 only recently so I'm thinking it's a setting I've missed. How do I change the fallback intent message in Lex V2?
The fallback message is defined by the fallback intent specified for your bot, which is always required to exist for any bot.
Even if you are building your Lex bot from scratch, there will be an intent of type AMAZON.FallbackIntent created for you with the default name of FallbackIntent.
To find the fallback intent for your bot - regardless of if it has been renamed from the default value - perform a search for AMAZON.FallbackIntent.
This will yield an intent:
You can then specify the 'fallback message' by:
Ensuring the Closing Response is set to active
Specifying a value in the Message field
I have an Amazon connect instance which uses a Lex v2 bot in the get customer input block. There is only one intent, which is triggered and reaches fulfillment fine. It is fulfilled by a lambda function and there are no errors there. It executes fully and there are not errors in the code.
I tested in the Lex v2 console and the bot works fine and returns the intent fulfilled message and the closing response. In the connect dialog flow, I get the intent fulfilled message and then nothing. No closing response and the dialog flow does not continue to the next prompt block, even when I remove the closing response. The call doesn't even hang up it just keeps the user on the line and is unresponsive. The lambda code fulfillment runs all the way through with no errors.
I suspect the issue is occurring somewhere between fulfilling the intent and sending the closing response. I don't know what could be holding up the bot at this point. I have a closing message I want to play for the user before I disconnect/terminate the call but the dialog flow is never getting to this point for reasons I cannot seem to find.
Any help is appreciated even just a point in the right direction. I have been looking through docs but haven't found anything regarding this specific issue. Thanks!
I have an aws lambda function which runs some python code (which is calling an external api with some extra functions). I attached a trigger, an api gateway, which if I go to the url, the lambda functions runs correctly.
However, I want the lambda function only to be run if they click on a button somewhere on the 'website' of the api-url. Rephrased otherwise, I want the api-url page to have a button, which on click executes the lambda function.
Im think that should be quite easy, however I can't figure out how. Due to the information overload I can't seem to find the right video, document example on how to do it.
Is the possible? (running the lambda function on click of a button). If so, is there some good documentation of example of this?
I tried to add a button on the api-url page by, on 'method-execution' on the 'api-gateway resource' page, changing the mapping template to text/html instead of json. (a bit like in https://blog.it-playground.eu/display-html-page-using-only-api-gateway/) But then i can't figure out how to run the lambda function onClick of the button. ==> Is this the right start?
(Because its not really a coding issue, I can't really provide any code).
Also, is this question so simply that it shows I simply don't understand the basics enough (and should subsequently go over them again)?
Of course this is possible. API Gateway exposes REST API. All you need to do is to create some resource and method in API Gateway such as
GET /posts
attach your lambda function to it, and hit that API endpoint with some ajax request from your front end (via fetch, axios, ...) that would be executed when the button is clicked. Something like:
button.addEventListener("click", () => {
fetch("https://my-api-gateway-url/posts").then() ...
}
You can process the response data in .then part but don't forget that this is asynchronous coding so you need to handle it as such.
I built the BookTrip bot from Amazon Lex detailed here.
When chatting with the bot the user can continue to book hotel rooms or rent cars until they end the conversation. Here is an example of a successful reservation followed by another reservation attempt through the chatbot interface:
When I use this chatbot in an Amazon Connect contact flow the user is not able to continue booking anything past the first reservation. Logically, the contact flow would keep executing the BookHotel or BookCar intents until the ConnectToAgent or EndConversation intents are executed.
I have tried looping BookHotel and BookCar back to the beginning of the "Get customer" input block but that errors out.
The best way to do this is keep the user in the bot until they have done all of their booking, and then exit back to Amazon Connect. You would do this in the following way:
Get slot values for initial booking
Use lambda to fullfil the intent (write to database, etc.) and clear the slot values
Use ConfrimIntent to as ask “would you like to add another booking”
If the user responds “yes”, confirming the intent then you would elicit the slot values (starting over at step 1)
If the user responds “no”, you would exit back to Amazon Connect
You can check out the lambda request and response details here
There is also a good discussion about this pattern on the AWS developer forum here.
I found one way around this that works for when you have multiple intents, though there are a couple drawbacks.
Basically, create a dummy block in Amazon Connect. I use Set Contact Attributes with a dummy attribute I named 'continue' with the value of 'continuing'. It is never used. Then on Success, loop it back to restart the Lex block!
No error when saving and publishing and works well for my use case.
Here's how the image above's set up works:
A. Play welcome prompt (this used to be the prompt when the Lex block initiated)
B. "Get customer input" is the Lex block.
C. Lex ends any intent and moves to dummy block (Set contact attributes)
D. On Success of setting dummy attribute, move back to restart B. Lex block.
Here are the drawbacks:
1. The Lex block requires some prompt when it initiates so you will have to design that into your bot, since it will deliver a prompt at the close of your intent, then another prompt at the restart of the Lex block.
2. This creates an infinite loop, at least until the user ends the call, or the session times out. One way around this though is to create an intent specifically for saying goodbye and don't point that intent fulfillment to the dummy block.
What I have implemented and successfully tested is adding "Greeting", "Yes" and "No" intents. When a real intent is fulfilled, I transfer the contact to the next Get customer input block that ask if the bot can help with anything else and checks for "Yes" and "No" intents. "Yes" transfers to the main Lex block. "No" obviously exits.
The key thing to me here is how do you set your text greetings so it doesn't seem confusing. Please see what I came up with on the flow diagram. Seems to be working to me.
P.S. Didn't test it in production.
I made a quiz skill where a user is first prompted with a response from Alexa asking if they are ready to proceed. From there, the user must either say yes or no to activate a corresponding AMAZON.YesIntent or AMAZON.NoIntent respectively. The quiz then begins, and a user says an answer letter followed by the answer for each question. I use a server to simulate state within my skill.
Normally I start my skill by saying:
"Alexa, start Quiz Skill"
But, I am finding that simulating state using a server does not make a very robust voice interface for the Echo. If a user says:
"Alexa, ask Quiz Skill yes"
The skill will jump to whatever I have setup to trigger when Amazon detects an AMAZON.YesIntent. This is not what I want! I want the user to follow the flow of the skill I have set out.
Is there a way to govern what intents can be activated at what time? A thought I had was to use attributes to basically set what intents are allowed to be invoked next.
There is a session object on each Alexa request. That session object has a new property that is either true or false depending on whether it's a brand new session for your Skill.
If you happen to be using the alexa-sdk node module to build your skill you can also use a NewSession handler to catch the new session and divert flow to what ever event/intent you want interaction to begin at. More on the state handlers can be found on the github page here
While I don't think it is possible to enable/disable intents, you can certain change how they respond. It's easy to use the session object to keep track of what the last intent spoken was. Then your intent handler(s) can read the session object to see what the previous response was in order to choose how to respond.
In your example above, you might save the last question number to the session object. If 'yes' doesn't make sense based on the previous (or lack of) question, then your YesIntent handler could respond with "I'm sorry, I don't know what to do with that", or even maybe just ignore it and start the dialog from the beginning.