dialogflow / dialogflow-dotnet-client

.NET framework for Dialogflow
Apache License 2.0
69 stars 50 forks source link

SessionId in query response #3

Closed brunobrandes closed 8 years ago

brunobrandes commented 8 years ago

Hello, My name is Bruno Brandes and I love learning about api.ai. I developed Alice. Alice is a insurance travel BOT using api.ai, Microsoft Bot Framework and Messaging Hub2.

My Agent in api.ai is configured to use webhook but when receives a call in my endpoint, I cant relate the request with my session because query response dosent contain sessionId passed query request :frowning:

My alternative for this problem was create a intents and context in api.ai for receiving text with "create session @sys.any:sessionId" and force my application call the api.ai in first user contact then finaly receiving query response with parameter sessionId.

I wonder... Contains another way to do this?

xVir commented 8 years ago

Hi, @brunobrandes Thanks for the suggestion!

I think, we will be able to add such field to the response data in upcoming update of API.AI. So, it will be available in about a week. I will notify you about the release.

Thanks, Danil.

xVir commented 8 years ago

Added in https://github.com/api-ai/api-ai-net/commit/013e582e53189956aaf146739116d86efcff8174

brunobrandes commented 8 years ago

Hello @xVir Thanks for this. The api.ai already returns sessionId property?

xVir commented 8 years ago

Hi, @brunobrandes No, but this field will be available soon and then I will update .NET lib in Nuget. Thanks!

xVir commented 8 years ago

Hi, @brunobrandes Api.ai now updated. Now you can get sessionId from response. Please check it.

Thanks!

brunobrandes commented 8 years ago

@xVir It's working :) Now, I can finish my project 'Alice'.

Thank you very much!

xVir commented 8 years ago

Great, Feel free to ask any questions :)

umashankarpandey commented 8 years ago

i am receiving warning in api.ai "IMPORTANT: Please use unique session ID for each client. Otherwise you may experience unstable behaviour"

what i need to do?

xVir commented 8 years ago

Hi, @umashankarpandey Did you get this message from SDK?

umashankarpandey commented 8 years ago

Yes i got this message but now working fine after

    var request = appai.textRequest(query);
request.sessionId="Your Client session ID"
request.on('response', function(response) {});
xVir commented 8 years ago

Yes, but I think it will be better to use some sort of unique identifier, UUID for example

let session = uuid.v1();

let request = apiaiService.textRequest(messageText, {  sessionId: session  });
request.on('response', function(response) {
    console.log(response);
});

request.on('error', function(error) {
    console.log(error);
});
umashankarpandey commented 8 years ago

OK Thanks for your help i will use it

felipemarquardt commented 5 years ago

Hello. i´m very very noob in programming... I´m search for some time now to request thru fulfillment, the sessionId to store on Firebase to control the user login. I tried the code above without success. Since it´s been 3 years now, does it still work the same way, or there´s another way of retrieving the sessionId?