Access follow up intent from main dialog - dialogflow-es

I am using dialogflow to create a simple bot.
Suppose I have an intent as follow. It works fine if user follow the flow given, where he need to answer like cat first and then answer yes before he/she able to see response of cat picture.
But Now I would like the bot to response in such a way that he/she need not follow exactly the flow given.
For example, if use say i would like to see a cat picture. Then the bot would response a cat picture and user need not go through the flow do you like cats.
Of course, I can copy and repeat each of the follow up intent. But this means that the code repeat itself.
What is the proper way to achieve such scenario?

you should be able to achieve this using Events, they are used to trigger an Intent.
In your case you define the event (EVENT_ASK_CAT) in the Intent page (after Contexts) and then trigger the event using the the fulfilment (webhook).
If you implement a Java webhook (using dialogflow.v2.model)
GoogleCloudDialogflowV2EventInput eventInput = new GoogleCloudDialogflowV2EventInput();
eventInput.setName("EVENT_ASK_CAT");
response.setFollowupEventInput(eventInput);
This would be the corresponding REST response:
{
"followupEventInput": {
"name": "EVENT_ASK_CAT"
},
"languageCode": "en-US"
}
You can also opt to use the inline Firebase editor if you don't want to deploy your own webhook.
Good luck!

Remember that Intents capture what the user says and not how you handle that.
In the example you give, you might create another top level Intent named "Ask for cat picture".
In your fulfillment code, both "Would you like to see a cat picture? - yes" and "Ask for cat picture" could call the same handler function. So there is no code duplication - they both just call the same function.

Related

Issues with attempting to enter intents

I'm having an issue when attempting to enter specific intents based on the value of a property.
I currently have a question that gets asked, which then fires off to the Microsoft Translator via a HTTP Request and from that, it fires off to the LUIS API with that text.
After that, I would like to enter an intent based on the top intent that the LUIS API Call brought back.
I have the Translator and The LUIS API bringing back values and I can output these using Send Responses:
However, when I attempt to call an intent based on the value of the property, I just get an Object Reference error:
Is what I'm trying to do possible and if so am I going about this entirely the wrong way causing more issues for myself?
Thanks In Advance
I'm trying to understand exactly what you are trying to achieve. Do I summarize it correctly as following?
You start a main dialog. In that dialog you take some user input.
You translate the input, and manually send the the translated text off to LUIS for intent recognition.
Based on the recognized intent, you want to start a specific sub dialog.
I don't believe you can just 'call an intent'. An intent is the result of a LUIS or Regex recognizer, which is processed automatically by Bot Framework. The recognizer is processed at every user input. There is no need to call LUIS yourself as a HTTP request. The recognizer (LUIS or RegEx) is configured on the main dialog properties in Bot Framework Composer:
Although in this case it looks like you are manually doing the LUIS intent recognition, because you want to do translation upfront. To achieve that scenario with the built-in recognizer, you would need a translation middleware. There is a short discussion going on here on Github about translation middleware for Bot Framework Composer, although the sample code is not ready yet.
While there is no code samples for the translation middleware yet, I believe what could already help you today is to start a subdialog based on the recognized intent, similar to what you already show in your screenshots.
Basically instead of "Send a response" at the end of your dialog, you would have something following like:
My sample here uses user input instead of the recognized intent. You would replace the user input with your intent variable instead. Based on the recognized intent, you would be able to spin up a specific dialog to handle that recognized intent.
The result would look something like:
About triggers, what you currently configured in your screenshot shows "no editor for null". I believe this might cause the "object reference" issue. Normally it should display a trigger phrase. For example, the below means:
If user inputs the text "triggerphrase"
And the dialog variable 'topintent' was previously set to 'test', then run this trigger.

How to ask the user to add new element in DialogFlow?

I am trying to build a bot in Dialogflow.
Here is what I need:
customer: Hello
bot: hello, what's your name?
customer: John
bot: Please enter the first element.
customer: element1
bot: Did you finish?
customer: No
bot: Please enter the second element.
....
Please advise how can I implement it? I am trying to create an intent with action and prompt but the agent doesn't ask me "Please enter the first element".
I also need to make first, second .. a counter that updates with each iteration / question.
Can you please advise where can I find a guideline how to achieve this kind task?
So far I have created an agent and playing with intents.
One way would be to write some code for fulfillment (using webhook or even inline editor), analyze incoming messages in your code and generate answer.
If you don't want to write any code, it should be also possible to achieve this using Dialogflow's context to store some information and followup intents to continue asking for elements. But in case you would like to ask user for multiple elements - it could be hard to maintain in Dialogflow. I have created and tested sample bot this way with following intents:
Please note that I have removed default Welcome intent to not interfere with custom "hello" intent.

Trigger one intent at the end of another

Sorry - very newbie question. I have a number of separate intents (let’s call them intent1, intent2, intent3, etc) which constitute a basic FAQ chatbot.
I want users to be able to trigger these independently but I’d also like to guide them from one to the next. So I’d like to be able, at the end of responding to intent1 to ask ‘would you like to hear about intent2 or ask another question’ and respond appropriately.
So far I’ve not messed with node backends etc so there is a possibility the answer lies there.
You don't need to use a fulfillment webhook, but it does make things somewhat easier.
First, remember that Intents handle what the user says, and not what you do with that. Dialogflow's responses appear to suggest they do, but once you get into more complicated interactions (where two different things from the user need to respond the same way), you find that the response section becomes less useful, and you should store your responses in code.
Those responses should include the prompt about the next question.
During fulfillment you should also set a Context (and possibly clear older contexts) to keep track of which question you are suggesting for them next.
This way - the next response will be triggered by two possible Intents:
One that directly asks a question.
In these cases, you'll use the Intent or action name to determine which question was asked, and provide an answer (and followup prompt).
One that responds "yes".
For this, you'll get the Context that includes information about the question you prompted them for, and provide that answer (and followup prompt).
While the "Followup Intent" feature sounds tempting, it is likely not what you want to use, since it does not allow multiple ways to access it and forces a very narrow path.
You may also wish to take a look at Thinking For Voice: Design Conversations, Not Logic for more about designing your conversation (and how to model it in Dialogflow, in a followup article).
okay, I am late here! Yes, It is possible with the event. I have recently done this.
function helloIntent(agent){
agent.add("Hi, how are you ?");
agent.setFollowupEvent({ name: 'NextIntentEvent', parameters: {} }); // this will do the trick
}
app.js
let intentMap = new Map();
intentMap.set("Hello Intent", helloIntent);
NextIntentEvent should be an event name defined in the intent that you want to trigger.
some code removed for brevity
If you want to make chain of conversation there are few options for that.
Slot filling
Here you need to add your questions as prompt and you can make that optional so if user wants to make the conversation they proceed by answering that question. Example
Contexts
You can set the follow-up question with contexts, Example
Events
Events are something that you can trigger from your web hook once you send the response of your current question,
To trigger the event, Example
POST Authorization: Bearer <AccessToken>
https://dialogflow.googleapis.com/v2/projects/<ProjectID>/agent/sessions/<SessionID>:detectIntent
{
"queryInput": {
"event": {
"name": "event-name",
"parameters": {
"parameter-name-1": "parameter-value-1",
"parameter-name-2": "parameter-value-2",
...
},
"languageCode": "en-US"
}
}
}

Dialogflow parameter entity similar to Alexa's AMAZON.SearchQuery

I've developed an Alexa skill and now I am in the process of porting it over to a Google action. At the center of my Alexa skill, I use AMAZON.SearchQuery slot type to capture free-form text messages. Is there an entity/parameter type that is similar for google actions? As an example, see the following interactions from my Alexa skill:
Alexa, tell my test app to say hello everyone my name is Corey
-> slot value = "hello everyone my name is Corey"
Alexa, tell my test app to say goodbye friends I'm logging off
-> slot value = "goodbye friends I'm logging off"
Yes, you have a few options depending on exactly what you want to accomplish as part of your Action.
Using #sys.any
The most equivalent entity type in Dialogflow is the built-in type #sys.any. To use this, you can create an Intent, give it a sample phrase, and select any of the text that would represent what you want included in the parameter. Then select the #sys.any entity type.
Afterwards, it would look something like this.
You may be tempted to select all the text in the sample phrase. Don't do this, since it messes up the training and parsing. Instead use...
Fallback Intents
The Fallback Intent is something that isn't available for Alexa. It is an Intent that gets triggered if there are no other Intents that would match. (It has some additional abilities when you're using Contexts, but thats another topic.)
Fallback Intents will send the entire contents of what the user said to your fulfillment webhook. To create a Fallback Intent, you can either use the default one that is provided, or from the list of Intents select the three dot menu next to the create button and then select "Create Fallback Intent"
So you may be tempted to just create a Fallback Intent if all you want is all the text that the user says. If that is the case, there is an easier way...
Use the Action SDK
If you have your own Natural Language Processing / Understanding (NLP/NLU) system, you don't need Dialogflow in the mix. You just want the Assistant to send you the result of the speech-to-text processing.
You can do this with the Action SDK. In many ways, it is similar to how ASK and Dialogflow work, but it has very basic Intents - most of the time it will just send your webhook a TEXT intent with the contents of what the user has said and let you process it.
Most of the Platform based ASR systems are mainly built on 3 main parameters
1. Intent - all sorts of logic will be written here
2. Entity - On which the intent will work
3. Response - After executing all the process this is what the user will able to hear.
There is another important parameter called webhook, it is used to interact with an external API.
the basic functionalities are the same for all the platforms, already used dialogflow(google developed this platform- supports most of the platforms even Alexa too), Alexa, Watson(developed by IBM).
remember one thing that to get a precise result giving proper training phases is very much important as the o/p hugely depends on the sample input.

actions_intent_CANCEL not working as expected

I am trying to follow this great article on Medium written by Jessica Dene. When users say a global cancel command such as "quit", I want my action to respond with a "goodbye" message. I have tried to follow the instructions provided by Jessica as illustrated below:
Add the actions_intent_CANCEL event to my end intent
Know More - no - no is my end intent. As you can see below, when I try to add "actions_intent_CANCEL" under Events, I can't see it as a suggestion in the drop down
But given that actions_intent_CANCEL does exist according to docs, I added it
Error
I saved the intent and tried in the web simulator, I see the below error
Any idea why I am getting this error?
Typing actions_intent_CANCEL in directly was completely appropriate. Most of the ones in the dropdown are for Welcome-like intents rather that in-conversation events that can occur. You have the right action name.
It sounds like you're handling it mostly correctly. The only additional thing you need to do is to explicitly close the conversation.
If you are using a webhook for fulfillment, how you do this depends on the library you're using (assuming you're using a library).
If you're using the actions-on-google library you would use the conv.close() function:
conv.close(`Okay, let's try this again later.`);
With the dialogflow-fulfillment library, it would be agent.end():
agent.end(`Okay, let's try this again later.`);
If you're using multivocal, you can either set the environment setting ShouldClose to true, or set it to true in a Response.
Response: {
"Action.multivocal.welcome": [
{
Template: {
Text: "Hello world."
},
ShouldClose: true
}
]
}
If you are using JSON, you can set payload.data.expectUserResponse to false.
Finally, if you are not using a webhook for fulfillment, but are just using the Responses section of Dialogflow, you would turn "Set this intent as end of conversation" on.
Yes, the actions_intent_CANCEL is removed from the docs and also from the dropdown list of events in Dialogflow.
So for exiting the conversation, you can try the following:--
(1) make an entity entry having all quotes for exiting the conversation e.g:-- bye, goodbye, bbye, talk to you later.
(2) make an intent having examples of the users leaving the conversation e.g:- I have some work, bye for now.
(3) And select the end conversation tap at the bottom of the intent so that conversation ends with the sample response.
(4) Also make a suggestion example for BYE/CANCEL with all the intents for better conversation flow
Using the above steps, you can mimic the actions_intent_CANCEL event

Resources