Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dialogflow - Node SDK does not preserve contexts within session

I'm using the dialogflow Node SDK to send textRequests and eventRequests to dialog flow. The fulfillment webhook shows that the context is not preserved though the sessionId is the same. Working with the same dialogflow agent from actions-on-google assistant, the context is preserved. so the only difference is that i'm using the Node SDK to send the text.

this.app = apiai(CLIENT_ACCESS_TOKEN);
this.options = {
      sessionId: 'abc',
      originalRequest: {
        data: {
          user: 'temp_user'
        },
        conversation: {
          "conversationId": "123456789"
        }
      }
    };

const request = this.app.textRequest('This is captured by INTENT_1 that triggers 
    a webhook that sets context to MY_CONTEXT', options);

const request = this.app.textRequest('This should be captured by INTENT_2 
    that has an input context of MY_CONTEXT', options);

the second request does not trigger INTENT_2, but the default fallback intent, unless I remove the input context from INTENT_2 in dialogflow and then it's triggered

like image 431
moshe k Avatar asked Oct 28 '22 21:10

moshe k


1 Answers

Might you be using resetContexts by mistake? That would explain it.

like image 95
eran Avatar answered Nov 15 '22 08:11

eran