title: How could I detect an Intent with a context ? (node.js SDK for Dialogflow API V2)
body: <p>How could I detect an Intent with a context ?</p>
  
  <p>I defined an Intent "Book" with an input Context "Activity", then trained my bot with "Book this activity in my schedule".
  I don't want to use dialog flow to manage context flow because it may evolve from other inputs in my app. So I want pass it as a parameter for each intent detection.
  I use node.js SDK for Dialogflow API V2.</p>
  
  <p>I precise it works fine with REST API v1 ... I think i'm stuck with API v2 Contexts :)
  I'm looking to do exactly the same as the following code with API v2</p>
  
  <pre><code>//code below is working fine
  import apiai from 'apiai';// Dialogflow SDK v1
  import uuidv4 from 'uuid/v4';
  const sessionId = uuidv4();
  const api = apiai('myToken');
  const lang = 'en-US';
  
    const request = api.textRequest('Book this activity in my schedule', {
      sessionId,
      lang,
      contexts : [{ name : 'activity' }],
    });
  
    request.on('response', function(response) {
      console.log(response);
    });
  
    request.on('error', function(error) {
      console.log(error);
    });
  
    request.end();
  </code></pre>
  
  <p>I didn't found documentation or exemple to do that except API documentation so I probably did something wrong</p>
  
  <p>Whenever I pass a context as a queryParams or create a Context it don't work.
  It also seems that context creation from API don't work at all.</p>
  
  <pre><code>import dialogflow from 'dialogflow';//Dialogflow SDK v2
  import uuidv4 from 'uuid/v4';
  const projectId = 'myID';
  const sessionId = uuidv4();
  const languageCode = 'en-US';
  const sessionClient = new dialogflow.SessionsClient();
  const contextClient = new dialogflow.ContextsClient();
  const sessionPath = sessionClient.sessionPath(projectId, sessionId);
  
  ...
  </code></pre>
  
  <p>First try returned my Default Fallback Intent  :</p>
  
  <pre><code>const request = {
      session     : sessionPath,
      queryParams : {
        context : {
          parent : sessionPath,
          name   : contextClient.contextPath(
            projectId,
            sessionId,
            'activity'
          ),
        },
      },
      queryInput : {
        text : {
          text         : 'Book this activity in my schedule',
          languageCode : languageCode,
        },
      },
    };
  
  sessionClient.detectIntent(request)
      .then(responses =&gt; {
        const result = responses[0].queryResult;
        if (result.intent) {
          console.log(result.intent.displayName);
        } else {
          console.log('  No intent matched.');
        }
      });
  </code></pre>
  
  <p>Second try returned my Default Fallback Intent  :</p>
  
  <pre><code>contextClient
      .createContext({
        parent  : sessionPath,
        context : {
          name : contextClient.contextPath(
            projectId,
            sessionId,
            'activity'
          ),
        },
      })
      .then(() =&gt; contextClient.listContexts({ parent : sessionPath }))
      .then(contexts =&gt; {
        console.log(contexts);//returned an empty list
        return sessionClient.detectIntent(request);
      }).then(responses =&gt; {
        const result = responses[0].queryResult;
        if (result.intent) {
          console.log(result.intent.displayName);
        } else {
          console.log('  No intent matched.');
        }
      });
  </code></pre>
  
  <p>Anybody see what's wrong with it ?
  Help needed :)</p>