https://discord.gg/botpress logo
Sub Workflow execution error
# 🤝help
h
Hi team, I’m new to Botpress and working on a client’s dating-app bot. I’m facing an issue where the paywall does not execute even though the hook sets the correct variables. 🔍 Objective On every incoming user message, before any response: If user.trialExpired === true → execute PaywallFlow If user.trialExpired === false → respond via Autonomous Node 📍 Bot Structure Main Agent with one Autonomous Node (prompt + knowledge base) Separate workflows: StartConsult EndConsult PaywallFlow Workflows only run if explicitly executed ✅ Hook Logic (Working) Location: subscriptionCheck (Before Incoming) Runs on every text message Increments conversationCount Sets trialExpired = true when count > 3 Logs confirm values update correctly event.state.user.conversationCount = nextCount event.state.user.trialExpired = nextCount > 3 ✔️ trialExpired is boolean ✔️ Values persist correctly ❌ Main Issue Main Workflow Standard Node with condition: user.trialExpired == true If true → execute PaywallFlow Else → Autonomous Node Actual behavior Even when trialExpired === true Transition never fires Bot always responds via Autonomous Node PaywallFlow is never executed https://cdn.discordapp.com/attachments/1466778579877494795/1466778580121030676/vetting-chatbot.PNG?ex=697dfb80&is=697caa00&hm=5679af1d5fd57884ebc742fe9b156a6621314b1518411a283a62233d8caeb191&
w
is your trialExpired variable a string or a boolean?
=== means you're comparing types as well
h
boolean
w
could you place a text node above the two transitions and output the variable there please
{{user.trialExpired}}
w
yes
@hundreds-plumber-89673 try changing your IF
from true to TRUE
h
ok
w
your IF is ==
try using ===
user.trialExpired === TRUE
h
I TRY IT STILL RUNING AUTONOMUS NODE
Can you please help me out?
l
Where are you stuck currently?
h
and if i add text card so if usertrialexpired==false its return error
l
You can try transitioning via autonomous nodes too instead of transition cards., in the instructions say usertrialexpired==true, transition to workflow2 ETC.
if all fails i'll take a look at your bot directly!
h
if my workflow is not in main agent it still? execute?
l
It can yes, you can also route back to the main and continue the flow
like this for example:
h
in instruction i add all the instruction for chatbot my prompt and add knowledge based also also i have one more question should i remove text card and direct attach autonmous to start ? https://cdn.discordapp.com/attachments/1466778579877494795/1466862552716808385/image.png?ex=697e49b5&is=697cf835&hm=789f2d5a36b9678a3f386f4ca11aa407bd656b4c08bb9ca0f762fd215558e91b&
l
You can try that yeah! See if the outcome is favorable in your case.
h
its my second message log from same user it does not show true or false and it just calculate user.trialExpired in first message only but i want that i calculate in every message https://cdn.discordapp.com/attachments/1466778579877494795/1467958117261377699/image.png?ex=69824608&is=6980f488&hm=0c15582fe36ca1952b59c99c1b1830d92bd33c40697b01506bc1a69f81cad480&
i want that if one user sent more than 3 message ai i did not respond and said to upgrade plan
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
2 Views