New request while a previous one is processing

I set up a flow that receives a token via telegram to make a GET on an API, which keeps looping until a certain condition is true and responds to the telegram with the result received.
The problem is that if there is more than one call, the previous loop is replaced by the new one.
Is this normal behavior or am I doing something wrong?
If this is normal behavior, there can never be a bot with many simultaneous users.

Thanks a lot

It is going to depend on how you've coded it. You will need to share more if you need more specific help.

Is what normal behaviour? Receiving more than one call, or the problem with the flow when that happens? As Dave said, if it is the flow that is the problem then you need to adjust the flow to cope with the case when there is more than one call.

Hello!
Thanks for the responses.
I have this


When i send message received by Receiver BotTestCBbot, this start one http request to check status on my http service.
While the status is QUEUE, delayed new request in 30' and retry, until the status is not equal QUEUE, then reply to the chatId has started the chat: "PROCESSED".
If only one person talk with the bot, works like a charm.
But, if a second one start chat, the first never receive a response, and the second receive his response.

What are you doing in those Function nodes? Are you storing state in context? If so, you need to make sure you key it to the individual request somehow, so each request is handled separately.

I believe it is just that ... But I don't know how to fix it :frowning:

In the first function i do this:

flow.set('chatId', msg.payload.chatId);
flow.set('type', msg.payload.type);
flow.set('txt', msg.payload.content);

msg.lote = msg.payload.content;

return msg;

And, in the second, this:

msg.payload.chatId = flow.get('chatId');
msg.payload.type = flow.get('type');
msg.payload.content = 'Done!'
return msg;

And my http request make get on http://localhost:3333/status/{{{lote}}}

Thank you.

rather than use context - you could just move them to other properties on the msg - eg msg.chatId = msg.payload.chatId - and then the reverse later - so they will stay with the msg passing through.

But in this case http get wil not discard the input msg and generate new one in output?

It shouldn’t. It will replace the payload but leave other properties alone hence why I suggested moving them out of payload.

1 Like

Very nice! Now it works with more users.
Thank you very much!

This is the flow! If anyone need this..

[{"id":"4aba3d89.d3ee14","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"cb1150d0.527ba","type":"telegram receiver","z":"4aba3d89.d3ee14","name":"Receiver BotName","bot":"7bb9463f.4d4ab8","saveDataDir":"","filterCommands":false,"x":120,"y":167,"wires":[["f69a002f.1736d","5b1181c2.9921b"],[]]},{"id":"f69a002f.1736d","type":"debug","z":"4aba3d89.d3ee14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":350,"y":87,"wires":[]},{"id":"5b1181c2.9921b","type":"function","z":"4aba3d89.d3ee14","name":"","func":"msg.chatId = msg.payload.chatId;\nmsg.type = msg.payload.type;\nmsg.content = msg.payload.content;\nmsg.lote = msg.payload.content;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":140,"wires":[["68c2b7bd.2b02c8"]]},{"id":"68c2b7bd.2b02c8","type":"http request","z":"4aba3d89.d3ee14","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.0.105:3333/status/{{{lote}}}","tls":"","persist":false,"proxy":"","authType":"","x":570,"y":120,"wires":[["c964f84c.1e3008"]]},{"id":"c964f84c.1e3008","type":"switch","z":"4aba3d89.d3ee14","name":"CheckStatus","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"QUEUE","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":380,"wires":[["d6fa7d35.901d2","b3790f1b.5761b"],["b3790f1b.5761b","3e5b5ec.d322ba2"]]},{"id":"b3790f1b.5761b","type":"debug","z":"4aba3d89.d3ee14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1030,"y":147,"wires":[]},{"id":"63ed5c3.625b7a4","type":"telegram sender","z":"4aba3d89.d3ee14","name":"Sender BotName","bot":"7bb9463f.4d4ab8","haserroroutput":false,"outputs":1,"x":1070,"y":307,"wires":[[]]},{"id":"d6fa7d35.901d2","type":"delay","z":"4aba3d89.d3ee14","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":700,"y":227,"wires":[["68c2b7bd.2b02c8"]]},{"id":"3e5b5ec.d322ba2","type":"function","z":"4aba3d89.d3ee14","name":"","func":"msg.payload.chatId = msg.chatId;\nmsg.payload.type = msg.type;\nmsg.payload.content = 'Done! ' + msg.lote  \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":870,"y":327,"wires":[["63ed5c3.625b7a4"]]},{"id":"7bb9463f.4d4ab8","type":"telegram bot","botname":"YourBotName","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]

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