Reputation: 345
If the user has already given me his name in entirely different intent, I store it in my DB. However I need to request it again in another intent where webhook slot filling is enabled and given_name is a required value.
But if he has already given it to me, then there is no need to ask, so I want to grab the stored name in DB and fill the parameter (given_name) with this value, so I don't need to ask
How can I do this? Can I directly alter parameter values with my webhook?
Upvotes: 1
Views: 285
Reputation: 3241
Wouldn't it be possible to call you DB instead of using the parameter values? If your database returns a name, you know that your user has mentioned a name in a previous intent before. From there you can just use the response from your database. If your database doesn't send back a name, then you would know when to ask your user about their name.
A simple example of this would be:
async function handleUsername(agent) {
// Check if the user has mentioned a name before in your DB.
const username = await callDatabase();
if (!userName) {
// Ask the user for their name.
}
// Continue the conversation.
}
Note: Since you mentioned that you are checking if the user had mentioned their name in multiple intents, it would nice to re-use the handleUsername()
function across your webhook, if possible.
Upvotes: 1