Dialogflow fulfillment - querying firebase with parameters from user - dialogflow-es

I am currently working on a dialogflow app for my company. I need to get our app to be able to take any name given by the user and match it to the database.
We manufacture CNC machines and we are attempting to create an application that allows the user to obtain information about their machine using their phone or google home. We have a website that allows them to give their machine a name. This name could be anything. It could be "Zodiac", or it could be "ZMachine #123". This name is stored in the database and is used to reference the machine from the dialogflow app. However, when google parses the voice input, and I get that entity in the fulfilment, I end up with "z machine number 123" or something like that, which I cannot match to the database directly. This is especially true for names that are not standard English words or names, such as a company name or something like that.
I was wondering if anyone had any resources that could point me in the right direction? I noticed that when you name smart devices in google, you can name them anything you like and it still gets it right. What are they doing in the background that allows this to take place?

Related

Dialogflow: how to automatically translate intents via Google Translate API over user requests

I'm really stuck at the process of auto-translation...
There is someone who can do a clear tutorial on how to automatically translate intents via Google Translate API over user request?
Searching all over the internet and haven't found anything clear...
I just need that if a Spanish user (for example) writes to my chatbot, the source language where the dialogflow agent is programmed is automatically translated to the detected one (Spanish in this case)

Dialogflow Integration into Custom CRM

I am trying to wrap my head around using Dialogflow for developing and integrating an SMS chatbot with our custom CRM. The creation of an Intent is pretty powerful and straight forward. However, I am trying to understand best practices for something. If I have an intent used to return the price of a service at a certain location, I can model that very easily within dialog flow. However, when an SMS message comes in, it will be from a new customer or a known existing customer for a certain location. For existing customers, we already know the location and therefore don't want them to have to specify the location value in the intent. Prior to sending the inbound SMS message to the client API to match the intent, how can I pre-set the "location" parameter value in the intent so it does exists even if that inbound SMS message did not include it? For example a known customer in Dallas would just have to say "how much is a xxx" instead of "how much is a xxx in Dallas".
Can you use the API to set a parameter value prior to calling the API to try and match the intent? If so, how do you get do that without a session ID? The reason the "location" is needed is because when we get to the fulfillment, the prices for the same service are different based on the location so I will need to be known but we don't want to make existing customers say the location.
Maybe another option is to have a Location intent with an event that we can trigger through the API. this would have an output context on it called location and fulfillment that sets the parameter value. But even then I struggle with understanding how to pass in values like location, phone number, etc into dialogflow from the calling application so dialogflow has those parameter values to use in fulfillment.
Reading documentation, watching videos and starting to test client API v2
This is certainly possible. What you would want to do is use the Dialogflow API for this. Here you can find the languages for which Google has created client libraries: https://cloud.google.com/dialogflow/docs/reference/libraries/overview
As soon as you have any 'if' in your code you should use the fulfillment: https://dialogflow.com/docs/fulfillment
How I would handle this:
Client sends SMS
You check in your back-end if this user is known. If known -> don't ask location, else you ask the location
Match the user query against the Dialogflow client library
Dialogflow will return the intent if (any) is matched
You should define and implement any logic before calling the Dialogflow library.

How to gather user information like name and mobile number before Chatbot starts conversation in Dialogflow?

I need to gather the name and mob number of the user before he starts interacting with the Chatbot. How can I do that?
You will need to create 2 parameters - name and phoneNumber to capture name and phone numbers.
Using the #sys.phone-number you can capture phone numbers from the user.
Using the #sys.given-name or #sys.last-name you can capture user's name.
Please note: currently only US English names are supported by the system entities in Dialogflow. So there may be some cases where you may not be able to capture all the names.
gather user information like name and mobile number before Chatbot
In your case, you need to use events
Step 1. trigger an event when your app initialize like from nodejs server and angular
Events are another way to trigger the intent without user interaction
when you intent trigger you can ask information

Dialogflow v2 user input and fulfillment

I am writing a Dialogflow v2 chatbot with Actions on Google.
I am asking for users to create a list and then have the option for ordering them.
I need to get a few pieces of information from the user. Her name, phone number and address.
Then I need the name of the vendor and their mobile number where the order will be forwarded.
If they have already given their name, I want to show it to them and have them confirm it.
The problem is that everything is an intent.
As an example they say Order from my list. I have to ask them for a store name e.g. Walmart. Now the problem is that I may not have all the vendors in an entity list. And if they just say Walmart, how do I know if it's a vendor name. I know I could have a follow up intent but not sure what happens when they don't say the right thing.
Basically, this is how I want the conversation to go.
They create a list which I have working.
Then they say order from list
Chatbot ask for the name of the store and mobile number to order from
Chatbot checks the name in the database and if doesn't exist adds it.
Asks for name, number address of the user
Shows the order, the vendor and the user's name and address
Passes this information to the server fulfillment hook.
Next time it needs to sense that it knows the user name, address and number and ask the user to confirm.
In simple terms, you would need to rely on contexts and webhook for validating the store name.
If the store is not valid, reset the context (same as input) and politely ask the user to provide the right store name.
Maintain a counter in parameters to keep track of the number of wrong attempts.
Increment that counter when wrong, reset when correct.
If the counter reaches 3 or 4, politely reply back that you could not serve them this that vendor and ask them to try the app later.
If this assistant app is US based you may need to add Transaction API as well to show the final order and confirm back to the user. Transaction API is available in the US as of now so keep that in mind.

How to locally store user information when he is using facebook messenger chatbot?

I followed facebook's documentation and set up my messenger bot. It works fine when it's just me who's using it, but I don't know how to create variables and store information in them locally so that I can have individual information about each user.
For eg. If I ask them to type their phone number, how/where should I save it, so that it isn't overwritten if a new user comes and inputs his number (which happens, if the variable is declared globally), and I can also use it later.
I used Node JS and followed the steps they mentioned in the documentation.
You have node js server as a backend which can communicate to a (mysql/sqlite) database.
Fb provides senderId with each request and also there is another graph API for getting user's other information like Name, Age, Gender, profile pic link etc
https://graph.facebook.com/v2.6/SENDER_ID?access_token=YOUR_TOKEN
You can have a table in your (mysql/sqlite) database where you can store senderId as a unique key and other information including phone number (which you are getting by asking user) in other columns.
Here's the documentation link for public profile API.

Resources