https://discord.gg/botpress logo
message count error
# 🤝help
h
i make a workflow where i add autonmous add also sub workflow i just add a logic where every message will count when user message greater than 3 so user.trialEpired==true i add a standard card at start of workflow where i add text card {{user.trialExpired}} and attach autonmous node where i add instruction when user.trialExpired==true you have to sent the message that your trial is expired or if user.trialexpired==false continue the conservation but the issue is that this standard card is execute only on user first message not every message you can see it start calculating on users 1 message not every message here my first message log and its my second message log heres my hook code async function hook(event: IO.IncomingEvent): Promise { / Your code starts below */ if (event.type !== 'text') return // Initialize user state event.state.user = event.state.user {} // Increment count const currentCount = Number(event.state.user.conversationCount 0) const nextCount = currentCount + 1 // Store BOTH in USER scope event.state.user.conversationCount = nextCount event.state.user.trialExpired = nextCount > 3 event.state.user.subscriptionTier = 'free' // Debug console.log('=====================================') console.log('USER ID:', event.userId) console.log('TOTAL MESSAGES:', nextCount) console.log('TRIAL EXPIRED:', event.state.user.trialExpired) console.log('=====================================') / Your code ends here */ } heres my hook code https://cdn.discordapp.com/attachments/1468514699078533150/1468514699397304412/image.png?ex=69844c64&is=6982fae4&hm=8a8aab2dd04e6dedb388543e21039b1fd93d98432bf285bff1d05a25f2164fef& https://cdn.discordapp.com/attachments/1468514699078533150/1468514700055679142/image.png?ex=69844c64&is=6982fae4&hm=c645919de09d1bae5b75a3ebf6be1ca64931baf14904f0d86eb50a6a68919dd4&
l
Can you drop a screenshot of your workflow?
w
I also need to count messages in an autonomous node, and I use a conversation variable. Then I ask autonomous node to add 1 on every answer it gives the use. You have to give Variable access to the node. Now the problem I have, is the transition in autonomous node. The condition is the messageCount variable is 3, but when the variable {{conversation.messageCount}} arribes to 3, the transition does nothing. It's something random, because the first time I've tried it, it worked. Also, sometimes autonomous node doesn't update the variable...
3 Views