I'm new to using Dialogflow,and I want to create a simple DialogFlow bot that can answer basic addition,subtraction,multiplication,division questions.How would I code it that it responds to the specific question asked by the user? For example if I made a math intent, I used the training phase "What's 2 x 3", and I made the response "6". Now, I want to add more training phases and I need the bot to use the correct response. Also, another problem is that it would take an impossible amount of time to teach it every possible math question,so is there code I could use to change that?
The easiest way to be able to answer every combination of math question would be by using a fulfillment webhook. Here you can use code to do the calculations based on the user input. You could create an addition intent where you train the bot to recognize addition input and you would connect it to code in your webhook which can do additions and return the response. You can then also add intents for subtracting, multiplication and divisions and connect each of those intents to code which can do the math.
For the setup, you have two options. You can write code in the inline editor in Dialogflow or host your code in your own server and connect dialogflow to the url of that server. More info on that can be found here.
Related
Hi so I have a problem.
In Dialogflow, when I get a response to end the chat, I would like to ask the user for ratings.
so I've created 2 intents, "endchat" and "endchat2."
They both have the same training phrases, but it appears only endchat2 is being used (the most recently created intent)
How do I ensure that the chatbot randomly chooses an intent after a given response, instead of only using one intent? They have the same training phrases.
An alternate idea is in the attachments. The problem lies that I want the custom payload to only to appear after one of the text responses, (that being text response #1,) but not appear, if the chatbot decides to use text response #2. This is the reason I decide to make two separate intents, but it looks like that's not helping out because the bot is only using one intent.
Remember, Intents represent what the user says and does and not how you respond to that. So there is no way to "randomly choose an Intent" to use to respond.
What you can do, however, is setup a webhook for that Intent and determine how you wish to respond to what the user says. In some cases, you can thank them and end the conversation, while in others you can thank them, ask them the followup question, and set a Context so you can expect their reply.
Having the same / similar training phrase in multiple intents is an anti-pattern of bot design. Ultimately this confuses the bot and it leads to undefined behavior.
This should also trigger an warning in "Validation" with something like "Multiple intents share training phrases which are too similar:..." on the intents.
I am trying to build a questions and answers app in Dialogflow. The problem I am stuck is in asking user questions in sequence.
The tricky part is that we have 40 questions saved in Google Cloud SQL and out of these, the cloud function sends 1 random question.
Now the first follow-up intent with first random question is successfully triggered.
The problem we are facing is in calling the second or further follow-up intent. Since the questions are asked using fulfillment API, hence we are not sure what will be the next question and its answer.
We tried to build a follow-up sequence but it didn't worked. Following is the attached screenshot for reference.
Seeking help. Thanks in Advance.
You can go to the next intent having trained with a random user input by using context linking and #sys.any Entity in Dialogflow which is used to get the user input i.e Training Phrases in Dialogflow having any random phrases or text.
Image reference for Entity.
Image reference for context linking of a question
Image reference for context linking with previous question
Good day,
I am currently trying to create an intent that is able to put out responses depending on the user input. (The chatbot should be implemented on a website later)
Let's say we have an entity called cars with three entries: "Volkswagen" "Audi" "Ford".
Now when the user types in something with e.g. Audi in it, the response will correspond to this. Something like this: If Audi then give this response, if Ford then this response.
I couldn't find anything helpful yet.
Thank you in advance!
Remember that Intents represent what the user says and not how you handle this or how you reply. Although Dialogflow does offer the ability to respond to Intents, these aren't based on specific values that may appear in parameters.
There are, however, a variety of ways you can handle what you're doing, based on the rest of what you're trying to do.
Multiple Intents
One solution is to create an Intent for each type of thing that the user may talk about. You could then put the response you want for each in the response section of that Intent.
This is probably a bad approach, but may be useful in some ways. It requires you to duplicate phrases between the different Intents, which leads to a lot of duplication. On the upside, it does let you vary the replies, and truly represents the Intent of what the user is trying to say.
Using Parameters with Fulfillment
A better approach is to have a single Intent with many phrases representing what the users can ask. These phrases would have parameters of your Entity Type.
You can then enable Fulfillment for this Intent and write a Fulfillment webhook for the Intent that would look a the value of the parameter and send back an appropriate reply.
Using Parameters with DetectIntent
Since your ultimate goal is to embed this on a website, it may be more appropriate to have your website show something different based on what the user has said. (For example to show a picture of the car in another pane or links to different pages, to use your example of cars.)
In this case, your chat client (or a proxy) would be calling the DetectIntent API. You can structure your Intent similar to above, with parameters of the Entity Type, and the reply that is sent to your client would contain the Intent along with the value of the parameter. Your client then can check the value of the parameter and change the display accordingly.
I want to ask the users a few questions in my welcome intent and depending on their answers give them a particular output.
My problem is that, once the user answers the first question, the agent exits my welcome intent and tries to match with the next intent.
I thought I could solve this by matching it back to the welcome intent.
So ideally it should have gone like this :
Welcome intent -> 1st question -> user answer -> Welcome intent ->2nd question -> and so on
But actually this happens :
Welcome intent -> 1st question -> user answer ->Welcome intent -> 1st question
It will keep asking the first question.
To solve this , I started maintaining a flag for each question.
If question 1 was answered I would set its flag true and then use it to skip the first question when the welcome intent is matched for the second time.
This is a very convoluted way to do it and probably far from the best way to do it.
Can anyone point me in the right direction to implement it?
Thank you.
Edit : I have given up my old method. Let me explain what I want to do and then I can get guidance on the way I should implement it.
I have 16 different outputs and I would like to show one of them to the user depending on their answer to 4 questions. Each question will only have two answers as options and depending on the option chosen by the user for each question , I will pick one of the 16 outputs and display it to the user.
How do I accomplish this using diaglogflow node.js?
First of all remember that an Intent captures what the user says or does and not what you do with that information or how you reply to it. That part is best handled by your fulfillment. While we can use Contexts to limit which Intents will be considered for a user response they are probably most useful in this case to store your state and keep track of which questions have been asked and answered.
Under this scheme, your Intents remain responsible for capturing input and your fulfillment examines this input, changes state based on this input, and sends a reply based on the new state (what it needs to ask next). If the user's responses will be mostly the same (free form, or from the same set of phrases), you can even use the same Intent to capture this input and the fulfillment would use the state and input to determine what logic to execute. If you need different types of input, and thus different Intents, their handlers can still call common functions to do the processing and change the state/reply.
This is further discussed in Thinking for Code: Design conversations not logic
You can use the concept of the follow-up intents in Dialogflow Console to create a chain of questions/answers.
Here is an example of my chain of questions/answers:
Though I still strongly advise you to study also how input/output context works. Especially if you want to collect all user reply parameters in the one final fulfillment of the last step to avoid storing the user inputs in fulfillments attached to every intent of the chain.
I'm using wit to recognize different intents in a retail context. Some of them trigger (successfully) FAQ answers, other initiate a business logic.
Surprisingly, I'm having a lot of trouble with the most basics conversational intents, like answering a hi or hello. Specially if they come as a single word (it doesn't get hi or hello but it successfully returns the correct intent for hi buddy or hey dude). Obviously there's a high chance that the first thing an user would say is just a simple hello, any of you found the same issue? Any guidance on that?
It is actually the first time I experience this issue, and I haven't heard about it. Could it be related to the increasing number of intents created (now 15+)? I'm using trait as a search strategy.
Greetings intent
Click on image for a larger version of the image.
Thank you very much for your help,