I have scenario, where I have javascript front-end connected using AJAX communicating with Django-Rest-Framework backend. Users authenticate using JWT tokens. Backend is acting as chatbot and receiving/sending messages as JSON objects.

Now in some instances, I sent this data to infermedica API which does medical analyses. This API does not have direct "client keys". I need to pass JSON messages from the server (using headers to authenticate).

In many instances informedica sends, additional questions bot needs to ask from the client, in my case I have limited this to 15 questions. After this it's passing the response object back, consisting most likely medical condition. Based on the condition I then call 2 other endpoints giving treatment advice and a possibility to schedule appointments with suitable medical professional.

My question is what is the good way to store the state of these requests to make sure all the info is passed to informedica and that response is send back to a right user.

I would like this to be as real-time as possible. My considerations is to store session info using Redis on server side keeping the track of user and users requests as key values and passing messages back based on this.

Is there an alternative way of somehow passing the authentication state directly to the client without actually sending the keys?

Is there a good open source project where something like this is done so I could look at the code? Python preferred.

This would be highly useful as I could just use browser cache for the request information and I can pass correct type of JSON request directly from the client.

  • I been thinking this today so far I think the best idea is to just store user session data directly to database and write few methods that fire when parsing responses from informedica. – Kimmo Hintikka Jan 13 '17 at 17:50
  • 1
    Look at stateful paradigms like agents or actors, which can persist their state between processing messages. Or you can keep them in memory and decommission them when they reach end state. (depending on level of concurrency) – Kasey Speakman Feb 3 '17 at 18:15

With just 15 questions, you can keep the state in the client: send a representation of answers 1..5 along with question 6, put it in a hidden input so it comes back with the answer to question 6.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.