triggering expressions with variables
# 🤝help
s
So I have made a contact loop to collect people's contact info, but my expression functions isnt working. I am collecting 3 vars (phone, email and name), the loop feeds into one node that has 4 expressions. the first three expressions check the value of each var independently and if the value is empty, then it pushes them to a node that prompts the user for the empty var. once filled, it loops back to the OG node and checks the next var until it gts all 3 and then sends them back to the OG workflow. well, its suppossed to. I guess my question is about how to do this successfully. my coding experience is limited and maybe im not writing the expression correctly or im expecting too much from the expression function. right now i have this: 1. workflow.userName === "" 2. (!workflow.userName) how do i designate the var check correctly?
b
in programming terms an empty variable is 'undefined'
so to generate a transition (expression) using AI, we have to use that word
for example:

https://cdn.discordapp.com/attachments/1141416213503815731/1141418011769700442/Screenshot_2023-08-16_at_1.07.36_PM.png

https://cdn.discordapp.com/attachments/1141416213503815731/1141418122377699358/Screenshot_2023-08-16_at_1.08.03_PM.png

this will work in the setup I have, but I'm not sure how you've set up your inputs. it should work in theory though
s
let me test
ok so do i have to say soemthing else to send it if the condition is true?
it's still failing for me

https://cdn.discordapp.com/attachments/1141416213503815731/1141419806814392402/image.png

b
where's it checking for the value of userName in this image?
if you'd like, can you load a problem report with this bot and give me the report ID so I can test it myself?
s
Right here. First node from entry

https://cdn.discordapp.com/attachments/1141416213503815731/1141423782104420412/IMG_3908.png

b
no that I can see - I meant in the emulator portion 😛
s
Yea. Let me find it
b
I don't see that happening in the conversation snippet
botpress logo > report problem
s
So right here it goes to cl_Sales (which is the workflow ss) and then immediately back to sales wf as if it checked all the vars and none were undefined

https://cdn.discordapp.com/attachments/1141416213503815731/1141424403993858129/IMG_3909.png

So actually, it is continually not checking bc there is a similar expression at the beginning of sales wf that send to cl_sales of the phone number is missing
b
hmm
I wonder if it's because we're sending the variables across workflows
can you get me that report ID?
s
As soon as I get back to my pc. One sec
b
\o/
s
I’m thinking user variable for phone might be better?
407ce6a9-8dae-4212-a21c-5f0671b30d1c
b
hmm
it looks like the only one that's undefined is userPhone

https://cdn.discordapp.com/attachments/1141416213503815731/1141427491379101696/Screenshot_2023-08-16_at_1.45.12_PM.png

s
exaclty
the goal is to have it go down the vars one by one adn if its empty, it should ask the user for the info
b
yeah for sure
I'm trying to recreate the issue to understand what's causing it not to check
s
theres a similar call in the quotes wf before you select product type for teh quoe only for email
it seems to work
b
here's the problem - when you pass a variable between workflows, your bot is setting the value of the variable in the new workflow to X, so even though it's "empty", your bot isn't reading it as such

https://cdn.discordapp.com/attachments/1141416213503815731/1141429976764252160/Screenshot_2023-08-16_at_1.54.49_PM.png

now, how to fix this
ah there we go
s
user vars?
b
your instinct was correct, making this a user variable will work
yup!
s
bet
b
just wanted to test it out myself beforehand
s
fasho. u da illest
b
i try i try
one quick question! based on all the builds youve seen, am i making stuff more complicated than needed?
b
it
hahaha
it's tough to answer that
i think in general the litmus test should be: if you're able to work through your bot, then it's fine
s
not mad at that lol
b
but if you find that you're getting bogged down using the studio, then that's a sign something's more complicated than it needs to be
but Botpress is so flexible that there's no "right" or "wrong" way to do something
imo if it works for you it works for you
s
ur the king of non answer answers lol
ill take it tho
thankks again. this support sesh was legit
b
LOLOL so true so true
s
alright @User , i cant get it to fire 😦
do i need to call teh user vars differently?
typeof user.email === 'undefined'
b
okay lmao
this might be mb
try
typeof user.variable === ''
s
this one worked for me
!user.email || user.email.trim() === ''
now im getting it to fire, which is dope. buuuuut, now it keeps asking me for phone number even though it is recording the user.Phone var successfully
it seems like it doesnt update fast enough to record the input before it checks again
gonna redesign the loop
so i got it, but not exactly sure why lol