How to use Class Token in DialogFLow - dialogflow-es

I'm using for the first time DialogFlow and I'm trying to use Class Tokens. How can I use them? In the Inline Editor of the Fulfillment? Thank you in advance.

In order to use class tokens you must add your token in phrases array under the speechContexts parameter in the recognitionConfig which is passed as input to the detectIntent or detectStreamingIntent Function in your webhook code.
Checkout these links for reference.
https://cloud.google.com/speech-to-text/docs/speech-adaptation#class_tokens
https://cloud.google.com/dialogflow/es/docs/speech-adaptation
https://cloud.google.com/dialogflow/es/docs/how/detect-intent-stream

Related

DialogFlow: simple ways of passing parameters between intents and from previous context to the current context? (Without using fullfillment)

Hi I’m look in for simple solutions for passing values between intents and contexts.
I’ve tried to set output context (c1) for intent A, and use c1 as input context for intent B. However, I’m not able to access the parameters value within intent B. Do I have to use fullfillment to implement this ?
Besides, I also want to use the previous parameters’ value of intent A when intent A is triggered next time. Again, can we do this without using fullfillment?
If fullfillment is essential, can you give some guidance please?
Accessing parameter values from one intent to another where contexts are used can be done from the Console itself. Fulfillment Webhook response can also be used but for your use case this can be done from the Console itself.
You can refer to the below replication steps:
In the text response of Default Welcome Intent add Hi what is your name? and add an output context awaiting_name.
Create another Intent Get Name and in that pass “awaiting_name” as input context . Pass some training phrases like "john,sandeep,jacob" and map it with them to the #sys.given.name entity.
In the Get Name Intent the text response is Ok $name, what is your email address?. Add awaiting_email in the output context field of this intent.
Create another intent “Get Email” and add awaiting_email in the Input context. Add training phrases like "sandeep#abc.com","john#xyz.com" and map them with #sys.email entity.
When you want to fetch the parameter value from another intent to the present intent where context is used you need to call it by #context-name.parameter-name as per this doc.
My final output response is Thanks #awaiting_name.name we will contact you soon on $email

Give a variable response in Dialogflow without hardcoding in fulfillment

I'm working on a Dialogflow chatbot, and I'm currently giving the response hard coded in fulfillment using agent.add(). However, the product owner wants to be able to modify the wordings without having to change and redeploy code. What are the options for this, other than storing responses in a file or in a database? Is there a way to have variables in the response when you add it in the response section in the Dialogflow console, where that variable is set in fulfillment, but otherwise the response is given as per the response in the console? Is there a way to select which response is given out of the ones set in the Dialogflow console from fulfillment? I'm using the nodejs fulfillment library without actions on google.
I think you have two options:
Use one intent only with various parameters
You can have multiple variants of responses in one intent. These will be prioritized by the maximum parameters they can fill. For example, if you are sending parameter "a" to a single intent using detectIntent API, the second response here will be triggered and shown to the user.
This is a response1 without parameters
This is a response1 with parameter $a <-- This will be triggered
This is a response1 with parameter $a and $b
As a little hack, you can also send an empty unicode space character here, if you prefer not to generate any parameters on the backend. Not too clean, but would work.
Use events triggered from your backend
In this case, your webhook/backend would choose a proper event to call. Hence, you would have mutliple intents, each with a unique response. You can also combine this approach with the first point above. You can read more about events here.

DialogFlow Custom Payload with Context

I am trying to add in the custom payload wihin Dialogflow a text response along with an output context. How can this be done?
Custom payload does not contain output context.
If you want to add output context you need to add it in output contexts like in the image below :
Hope it helps.

How to get entities of type alpha-numeric using DialogFlow

I am creating a Google Action using DialogFlow, I require a user input for which the entity should be of alpha-numeric type(like part-number or order-number).
I have tried the system entity type #sys.flight-number, but it didn't help.
This is going to be difficult, as Dialogflow is not designed to match alpha-numeric characters. Trying to input a series of letters and numbers can be easily misinterpreted, especially if just being spoken. If you can, I'd recommend not doing that.
Perhaps the user inputs these characters using an app or website, then the Action will authenticate using Google Sign-In or OAuth and pull the values from your account.
Alternatively, your Dialogflow intent could have a custom alphanumeric entity marked as a list, and let the user input values using the phonentic alphabet.

How do I parse string response in api.ai?

While creating Intents in Api.ai, I can parse sys or user parameters as listed here:
https://docs.api.ai/docs/concept-entities#section-user-entities
However if I have to parse a string response, there isn't a way to add that as a parameter. Any workaround to parse a string response from user to fetch an entity?
Like for e.g.,
Customer's name is John.
I want to retrieve John in my action.
I think you can utilize api.ai Contexts to Achieve that..
check Context documentation
Yes , It is possible.
1)First you should set the output context in intent from which you want to fetch customer's name
e.g. setting output context
2) Then define the input context with same name in intent where you want to get your customer's name e.g. setting input context
3) then you can access name by defining the parameter with #<context_name>.<parameter_name> e.g. #send.name
Hope this might help!!

Resources