Search code examples
.netapi-ai

Pass SessionID to api.ai through dotnet sdk


This seems very trivial question, but I can't find a way to pass the SessionID through the ApiAi.TextRequest call


Solution

  • Okay, turns out its the sdk is built in a way to work only from client side. It generates the GUID internally:

        public AIDataService(AIConfiguration config)
        {
            this.config = config;
    
            if (string.IsNullOrEmpty(config.SessionId))
            {
                SessionId = Guid.NewGuid().ToString();
            }
            else
            {
                SessionId = config.SessionId;
            }
        }
    

    So what I ended up doing is to add the SessionId object to the ApiRequest object:

        [JsonProperty("sessionId")]
        public string SessionId { get; set; }
    

    Obviously you will need to refactor the methods signatures