1

I'm using dialogflow's fulfilment. When an intent is matched, there is a function in fulfilment that sets a parameter for the next intent via the input-context. In this case the user gives their name and i want to store the name as a parameter. What I don't quite get is how long the name will last as a parameter for that particular context? Because I don't really want to have to set the name repeatedly.

function nameFunc(agent)
{

        const name = request.body.queryResult.parameters.name;

        agent.setContext({
        "name": 'live-context',
        "lifespan": 1,
        "parameters": {
          "name": name,

1 Answers1

0

In short, the lifespan determines how long the Context remains (and thus how long the parameters in the Context remain).

Each time Dialogflow processes an Intent, it decrements the lifespan of all the Contexts that are currently active. When the lifespan reaches 0, the Context is removed.

You can also adjust the lifespan of any Context, either by setting it as part of the Outgoing Context field in the UI, or via your Fulfillment function.

Prisoner
  • 49,922
  • 7
  • 53
  • 105
  • Thanks @Prisoner. Yeah, that's what I thought. So if you want to remember the users name using contexts (I guess there are other options for this as well) you need to make sure that the contexts are alive for the duration of the dialog. –  Feb 22 '20 at 14:44
  • 1
    Yup. The two ways of doing this are either setting a huge lifespan (99 is typical) and/or resetting the lifespan every time. – Prisoner Feb 22 '20 at 15:02