Reputation: 315
I want to set agent.parameters using my fulfillment code in DialogFlow but I am not able to do it.
I am using:
agent.parameters.product=query;
Where query is:
var query=request.body.queryResult.queryText;
How can I set my product parameter by coding?
Upvotes: 1
Views: 2512
Reputation: 50741
The agent.parameters
field is read-only. It provides the parameters that were determined by Dialogflow for this Intent based on the training phrases and parameters for that Intent.
If you need the queryText - just use the query text.
Perhaps you are trying to set the parameters for a Context?
Update to answer questions from your comment
Can I change the parameters if I change the request body?
If you change them before you create the WebhookClient
, then probably. But don't do that.
Again, it isn't clear why you want to set this in a parameter and not just use the query value in some way.
How can I add parameters which are not system defined?
Writing code to populate a parameter defeats the purpose of intent detection in the first place, so it still isn't clear what you're trying to accomplish by doing so.
I have only one Intent
Typically, collecting information can be done over multiple Intents in the conversation, each one with parameters that have Entity Types attached to them. These Entities may be custom types, or may be more free-form.
Regardless - having only a Welcome Intent is unexpected, and it isn't clear why your bot framework requires this, or why you're doing it this way.
What about changing parameters with Output Contexts?
In typical Dialogflow conversations, you can create Output Contexts with some (possibly long) lifespan and set parameters to it. These parameters also are set by the current Intent parameters, so you need to make sure they don't conflict.
The good thing about Contexts, however, is that what you set as an Output Context from one Intent Handler is sent back to you as an Input Context in the next Intent (until the Lifespan hits 0). So you can use the parameters to store information that you need to use across multiple Intents.
BUT... I have no idea how this will work in your setup, where the Welcome Intent is called each time, since the bot framework need to actually re-send the Contexts that are part of the session.
Upvotes: 2