actions_intent_CANCEL not working as expected - dialogflow-es

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

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.

Access follow up intent from main dialog

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.

Handling "cancelling slot filling dialog"

I am building a bot which contains the Slot Filling approach and I want to provide a rich message from a webhook once an exit phrase is input to the bot.
I am building a bot which contains the Slot Filling approach. I came across through "cancelling slot filling dialog" in the documentation from the link https://dialogflow.com/docs/concepts/slot-filling#canceling_slot_filling_dialog
While I was trying it out, I found that not only the mentioned utterances in the documentation, there are more exit phrases like that. Ex: nothing, abort.
I couldn't find any intent/settings to configure/change this behaviour.
Is there a way that I could find out all the exit phrases?
Is there a way to change the output message displayed when the user says an exit phrase?
Can we connect with a webhook after user says an exit phrase to provide a custom rich response?
Attached is the response I get when I say an exit phrase to bot while slot filling
There's no built in way to do it as far as I can tell, but there is a hacky way you could use 3 to achieve 2. I'll assume you are familiar with how Dialogflow webhook requests and responses work generally. Please see here if not.
It basically boils down to checking if Dialogflow is about to respond with one of its stock cancellation phrases, then replacing it with one of your own.
Make sure "enable webhook call for slot filling" is on. When the user types a slot filling exit phrase, the webhook JSON that Dialogflow sends will still have the same intent.name property as the intent you're working with. So you can catch that intent in a switch statement.
Then inside that you can simply use an 'if' statement to check the "FulfillmentText" property of the webhook request and see if it's any of the stock phrases Dialogflow uses to respond to cancellations, such as "Sure, cancelling", or "No problem, cancelling". I don't know how many there are, but I assume there's not too many, you'll have to test to try and find them all.
If it is any of those phrases, you can then change what Dialogflow says to the user by giving back a response to the webhook with your own FulfillmentText set to whatever you want (see the link above with how the JSON response should be structured).
This method isn't exactly ideal as the stock exit responses Dialogflow uses could change and it's hard to know if you've found them all, but it should be a workaround until Dialogflow becomes more flexible.
Also copying my comment about question 1 before since it seems to work (thanks for the typo correction):
I suspect the list of cancelling phrases is the same as that found in the "cancel" intent of the prebuilt smalltalk agent. To find this, go to Prebuilt Agents -> Small Talk -> Import. Then navigate to that agent and find the intent "smalltalk.confirmation.cancel" to view the list of phrases.
Hope this helps.

Prompt for Text Without Routing

What I'd like to incorporate into my bot is a way to prompt the user for essentially free-form, natural language text and then save it.
I thought this would be simple enough using:
builder.Prompts.text(session, prompt);
But it appears the UniversalBot is attempting to interpret and route based on the text supplied by the user.
I do have LUIS wired into the bot as the recognizer and it's clear that's what is coming into play here because it's resolving to one of my defined intents. Or at least it's saying it recognizes that intent but it doesn't actually take the user to that dialog.
Is there some way to achieve what I'm after? Essentially disabling the recognizer while receiving the response to a prompt?
I'm coding in Node.
You can disable the LuisRecognizer by using .onEnabled(). You can find an example here on it in action. You'll need a condition to to enable and disable the LuisRecognizer, which could be checking the dialogStack, or setting a property inside of session.conversationData.
Alternatively, if you're okay with triggering the None intent, you can use .onFilter(). This will allow you to change the recognized intent to the None intent. Your condition here would be checking to make sure the dialogStack is empty. You can find an example for onFilter() here.

Webhook generated list fetch option selected by user

I'm pretty new in API.AI and Google Actions. I have a list of items which is generated by a fulfillment. I want to fetch the option selected by user. I've tried reading the documentation but I can't seem to understand it.
https://developers.google.com/actions/assistant/responses#handling_a_selected_item
I also tried setting follow up intents but it wont work. It always ends up giving fallback responses.
I'm trying to search a product or something and the result is displayed using list selector format. I want to fetch the option I selected. This a search_product intent and I have a follow up intent choose_product
You have two options to get information on a Actions on Google list/carousel selection event in API.AI:
Use API.AI's actions_intent_OPTION event
As Prisoner already mentioned, you can create an intent with actions_intent_OPTION. This intent will match queries that include a list/carousel selection as documented here.
Use a webhook
API.AI will pass the list/carousel selection to your webhook which can be retrieved by either:
A) using Google's Action on Google Node.js client library using the app.getContextArgument() method.
B) Use the originalRequest JSON attirbute in the body of the reques to your webhook to retrieve list/carousel selection events. The structure of a list/carousel selection event webhook request will look something like this:
{
"originalRequest": {
"data": {
"inputs": [
{
"rawInputs": [
{
"query": "Today's Word",
"inputType": "VOICE"
}
],
"arguments": [
{
"textValue": "Today's Word",
"name": "OPTION"
}
],
"intent": "actions.intent.OPTION"
}
],
...
This is a sideways answer to your question - but if you're new to Actions, then it may be that you're not really understanding the best approaches to designing your own Actions.
Instead of focusing on the more advanced response types (such as lists), focus instead on the conversation you want to have with your user. Don't try to limit their responses - expand on what you think you can accept. Focus on the basic conversational elements and your basic conversational responses.
Once you have implemented a good conversation, then you can go back and add elements which help that conversation. The list should be a suggestion of what the user can do, not a limit of what they must do.
With conversational interfaces, we must think outside the dialog box.
Include 'actions_intent_OPTION' in the event section of the intent that you are trying to trigger when an item is selected from list/carousel (both work).
Then use this code in the function that you will trigger in your webhook instead of getContextArguments() or getItemSelected():
const param = assistant.getArgument('OPTION');
OR
app.getArgument('OPTION');
depending on what you named your ApiAiApp (i.e.):
let Assistant = require('actions-on-google').ApiAiAssistant;
const assistant = new Assistant({request: req, response: response});
Then, proceed with how it's done in the rest of the example in the documentation for list/carousel helpers. I don't know exactly why this works, but this method apparently retrieves the actions_intent_OPTION parameter from the JSON request.
I think the issue is that responses that are generated by clicking on a list (as opposed to being spoken) end up with an event of actions_intent_OPTION, so API.AI requires you to do one of two things:
Either create an Intent with this Event (and other contexts, if you wish, to help determine which list is being handled) like this:
Or create a Fallback Intent with the specific Context you want (ie - not your Default Fallback Intent).
The latter seems like the best approach since it will also cover voice responses.
(Or do both, I guess.)

Resources