aponski
aponski

Reputation: 155

How to use Dialogflow environments (beta feature) in nodejs-dialogflow

How to call detectIntent but with specified Environment (beta feature) using Dialogflow nodejs SDK (nodejs-dialogflow)?

Upvotes: 4

Views: 853

Answers (1)

Marcos Casagrande
Marcos Casagrande

Reputation: 40394

You have to use dialogflow.v2beta1.SessionsClient & .environmentSessionPath instead of .sessionPath to generate the session that is sent on detectIntent

const client = new dialogflow.v2beta1.SessionsClient({});

const sessionPath = client.environmentSessionPath(project, environment, user, session);

// The text query request.
const request = {
  session: sessionPath,
  queryInput: {
    text: {
      text: 'hello'
    }
  }
};

This is the template for session environment path:

projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}

You can read the library code regarding this answer at https://github.com/googleapis/nodejs-dialogflow/blob/master/src/v2beta1/sessions_client.js#L353

More info at: https://dialogflow.com/docs/agents/versions-environments

Upvotes: 6

Related Questions