Leonard Niehaus
Leonard Niehaus

Reputation: 530

Actions on Google context not being passed to next intent

I am trying to pass values from one intent to another. This is how I set the context:

app.intent('welcome', async (conv) => {
    const parameters = {
      userId: "12345"
    };
    conv.contexts.set('userDoc', 5, parameters);
    conv.followup('second', {})
})

This is how I try to retrieve the context parameters:

app.intent('second', (conv) => {
  console.log(conv.userDoc); // returns undefined
})

However, conv.userDoc returns undefined.

This is my dialogflow setup:

dialogflow welcome screen dialogflow second screen

Upvotes: 1

Views: 77

Answers (1)

Prisoner
Prisoner

Reputation: 50731

Contexts are set as part of the reply that is sent back. Calling conv.followup() discards everything from the reply except for the event type and parameters that are sent.

In general - you probably don't want to actually use conv.followup() anyway. If you feel you need to return something from your webhook - just return it.

Upvotes: 1

Related Questions