Flow variables overwritten

I built a small program with telegram node that makes queries into a database and return it correctly at this time. There are some options on what to query and each one I have created a subflow to get things organized.

It works smoothly with one user but if another user tries to use the same routine it overwrites the flow variable tha was defined by the first one.

Example.
The routine first asks for a DocID, saves this answer from the user and keep this information to make the queries about this Doc. Then the user starts to search for specific informations about this Doc. So this DocID is used in all futures queries until the user exit the routine. Actually I save this DocID information into a flow variable and retrieve it on each query.

What happens is that when another user starts this same routine, the DocID it sends from telegram to make it's futures queries, overwrite the DocID of the first user and then both users are making queries using the same DocID saved lately into the flow variable.
I would like that each one works with it's own saved DocID number.

Sorry for any mistakes on english and even if this question is too noob. I am no programmer but an enthusiast.
Thanks in advance

Welcome to the forum @guga-mattos

That is one of the issues with using global and flow variables, which is why I try to avoid them whenever practical. If possible it is better to pass the docid along with the message so it is there when needed. You have not provided enough information to be able to make detailed suggestions, but you may, for example, be able to save the id in msg.DocID. Further nodes in the flow should not modify properties that they do not make use of, so that property should persist down the flow and later nodes can pick it up and use it.

If you have to use context you can also give each store context variable a unique ID, One you create yourself or msgid maybe. Then use the ID to store the context, then you can recall using ID. Remembering to clear up the store context at end or via a timestamp property on a hourly, daily, weekly, etc basis, or your context storage could grow out of control

Hi, Colin.
Thanks for the welcome, and thanks for the answer!
I was jus testing right now and it works until it goes thorugh another telegram sender node. This node just write a new msg variable ignoring all other properties (other msg properties deleted).
Now working on Join msg properties again!

But the main issue seams to be solved.
Than you one more time

1 Like

It worked in an easier way!
just added chatID into the variable name in every single flow.get and flow.set

Thanks E1cid!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.