0

I'm using dialogflow-fulfillment to implement the backend of my service based on dialogflow. There's a point where I use the method agent.setFollowupEvent(targetIntent), the targetIntent requires a context to be matchable, let's call it targetContext.

I can't tell exactly when it stopped working (a week? month maybe?), but it worked and right now it's not working (and I don't think I've changed anything that could explain it). The targetIntent fulfillment never get called and I can see in the dialogflow console that it's because the request triggered by setFollowupEvent doesn't match any intent.

If I remove the requirement of the targetContext from the targetIntent, it works.

I think I'm setting the context correctly:

agent.context.set(targetContext, null, null);
agent.setFollowupEvent(targetIntent);

Inspecting the body of the response that dialogflow-fulfillment is sending to dialogflow I see:

{
    "outputContexts": [{ "name": "projects/<myprojectid>/agent/sessions/<mysessionid>/contexts/<targetContext>" }],
    "followupEventInput": { "name": "<targetIntent>", "languageCode": "it" }
}

The context is there, and I think is correct. Any clues? The only thing I can think of is that we changed the agent type from free to enterprise.

flagg19
  • 1,782
  • 2
  • 22
  • 27

1 Answers1

2

Obviously, I've found the solution just after asking the question...

The problem was the lifespan of the context, I did not set it, now it works with:

                                 |
                                 V
agent.context.set(targetContext, 1, null);
agent.setFollowupEvent(targetIntent);

So the output become:

{
    "outputContexts": [{ "name": "projects/<myprojectid>/agent/sessions/<mysessionid>/contexts/<targetContext>", "lifespanCount": 1 }],
    "followupEventInput": { "name": "<targetIntent>", "languageCode": "it" }
}

Still I'm quite sure it worked before, maybe not setting the lifespan used to default to 1?

flagg19
  • 1,782
  • 2
  • 22
  • 27