I'm new to api.ai and I'm working on a VERY simple FB guided bot (bot asks question, user chooses from quick cards). Problem is, some of my questions are open, meaning the user can keep inputting information until they decide to move on to the next question.
My goal is to have something like this:
Bot: Hello. Please reply to this open question.
User: This is my reply's first paragraph. However I want to keep writing. (ENTER)
B: Anything else you would like to add? (quick button: "NO")
U: Yes, this other paragraph. (ENTER)
B: Anything else you would like to add? (quick button: "NO")
U: "NO" (Quick Button).
I can't figure out how to, no matter what the user writes, always give the same reply ("Anything else you would like to add?" and quick button "NO"), until the user has nothing else to say. How to keep the user in a closed loop (although a loop that is specific to that one question, as I have about 6 different ones of these).
Any advice on where to start looking?
I have found an easy way to do this using contexts. It seems to work, but I will keep an eye on alternatives.
In the step before introducing the question, output a context, for example, context-A.
Create a new Fallback Intent (from Intents > ...) with Input: context-A and Output: (1) context-A. The (1) is the number of iterations. This fallback intent is the one that asks the user to write if they want to, or click the button if they are done (the button takes them to the next question, where you can repeat the process if needed).
And that's it. Basically, you are creating a new context for this question to live in, and then looping the fallback intent until the user moves to the next one.
You might also be able use parameters and #sys.any.
Intent #1: What is your answer to this question?
-> Output Context: Answering
Intent #2: Continue answering or say Done.
-> Input Context: Answering
-> Output Context: Answering
-> User says: "x" and set the entirety of their response "x" to #sys.any, catching any value as 'not done'
-> User says: "done" then move on...
Related
I am creating an Alexa skill, but it got rejected by Amazon. The way my skill works is as follows,
User: "alexa, ask doctor is it safe to use vaccine during pregnancy"
Alexa: "gives a response, fetched from DynamoDB"
- (dialogState: Complete)
I got the following review comments from Amazon:
After the skill completes a task, the session remains open with no prompt to the user. The skill must close the session after fulfilling requests if it does not prompt the user for any input.
Can anyone help me with this?
I tried to use DelegateDialog but it doesn't seem to work.
handler_input.response_builder.add_directive(DelegateDirective())
.speak(message)
.ask(reprompt)
.set_card(SimpleCard("Custom", message))
I want Alexa to ask a question to the user, like "Do you have any other question?"
So that the conversation doesn't end and keeps going. I don't want to close the session right after Alexa sends the answer.
A couple of things:
delegate directive is when you want ASK(Alexa Skills Kit) to determine the next thing to speak. This only makes sense if you have a dialog model (requires slots, elicitation prompts, etc.) and the dialog is not yet completed. You do not seem to be using dialog model and at any case you are both delegating and providing speak() which I don't think is what you want.
For your scenario, you will likely want to produce a complete output that has both the answer and the next question. it can be as simple as string-append: message = db_response + ". Anything else?"
I am trying to create a quiz-bot, in which I wish to verify the users answers. I have created an intent to show questions and then a follow up intent to verify answers. Following is the brief idea:
When the user is shown the question, he/she is also shown the one word options as suggestion tiles, the user selects the suggestion tile (which he/she thinks is a correct answer), then the follow up intent should be triggered to verify the answer and the bot should respond as correct or incorrect answer.
As of now, I am able to show the question and options in the chat box, but as soon as the user selects the option, default fallback intent is triggered.
Also I have included all the answers in the intent's training and these answers are of one word length.
Is there a way to trigger intent using user's input? Also if there is any other approach to create quiz-bot in dialogflow, please do comment?
I have also created a quiz on Google home.
The same problem occurred to me and I came up with the following solution:
The Default Welcome Intent has an output context of await_answer and I ask the question in this intent.
Then there is the getAnswerIntent that has the await_answer as input context and has the answerCodeEntity as trainingsphrase. This entity consists of:
A: 1, A, answer 1, answer A, first, first one, the first one
B: 2, 2nd answer, second answer, answer B, B, ...
C: ...
D: ...
E.g.: How far away is the moon from the earth?
A: 384.000km
B: 50.000km
or C: 1.000.000 km
This way users know how to answer. You will avoid having users that can't say the answer or just don't remember. Always try to expect how a user will respond.
This way you can handle the user's answer in the getAnswerIntent.
I hope this helps you!
I am using contexts within Dialogflow to call the next intent for the user. What I would like to do is have the ability for someone to change their mind on an answer they just entered. For example, as seen in the image below, if I enter a name then it would ask for an email. However, the user should be able to say "can I change my name" and go back to the context where Dialogflow is asking for a name.
I already have that intent implemented but I am trying to figure out how to go back to the question they were going to answer before deciding to change their name. I can use fulfillment to capture the raw API response and possibly get the last context however how can I force the user after changing their name to go back their previous context/intent?
You can do this easily by using the fulfillment. You have to save the previous intent contexts and prompt as well as the next intent contexts and prompt in the parameters of the intent.
Currently I'm creating an Action for the Google Assistant.
In this Action, I ask the user to provide its phone number. After this, another intent will repeat the phone number given, and asks if it's correct. If the user responds with 'no', I would like to redirect the user back to the first intent, so it can provide its phone number again. It should be a kind of loop.
(I'm working in a local environment, so only the intents are created within Dialogflow.)
I tried to apply contexts for this case, but in someway it won't succeed.
Thank you guys!
Remember that Intents represent what the user has said, and not what you are doing with that data. So saying that "another intent will repeat the phone number" suggests that you're making some things more complicated.
A better design is likely to have the Intent that collected the data to several things:
Repeat the phone number back
Prompt if this is correct
Set a content indicating you have prompted for confirmation
You can then have another Intent handle the "yes" or "no" statements responding to this prompt. The user may say other things, remember, including giving a correction to the phone number.
See also these articles (based on a StackOverflow question and answer) on designing a conversation and the Dialogflow Intents based on that conversation:
Thinking for Voice: Design conversations, not logic
Conversation to Code (Part 1)
I've something that I don't succeed to understand.
Here the situation I would like to do :
Bot: Hello, what do you want to do ?
User: Search a product
Bot: Which
product are you looking for ?
User: Apple
Bot -> list of products
matched with apple
here is a fragment code :
function searchProduct() {
agent.add('Which product are you looking for ?');
// receive the product answer
//-> then research the matched product in DB
}
const intentMap = new Map();
intentMap.set('I want a product', searchProduct);
agent.handleRequest(intentMap);
In this code, I ask to user the product that he's looking for.
But when he answered "Apple", how can I receive the user response in the same function to continue my process ?
I know there is the "context" concept, but to continue the "search product" process, I need to come back in the function.
For now, I use dialog-fulfillment. And I try to understand this documentation to find the solution :
https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/master/docs/WebhookClient.md
The short answer is that you can't (or, at the very least, shouldn't) do it in the "same" function. Each function represents an Intent, or what the user has communicated to us. In the function we need to do the following:
Determine what the user has said that is important to us.
Compute anything based on what they've said.
Send a reply to the user based on (1) and (2).
Once we have sent the reply to the user - that round of the conversation is over. We need to wait for the next Intent to be triggered by the user so we can repeat the above.
Contexts are used so we know which stage of the overall conversation we're in. As part of our reply (step 3 above), we can set a Context which will help Dialogflow determine which Intent should be triggered (and thus which function should be called to process what we know so far). Contexts can also store information about previous turns of the conversation.
Keep in mind that Intents aren't about what we say, but are about what the user says. The reply we send is based on what we need, and then we would use a single Intent to capture each part. The function that handles that Intent would store the answer in the Context and determine the next part of the question.