How to select specific variable to reply to the us...
# 🤝help
s
Hey guys, would be super grateful if someone could help me out here. I am asking the bot to dtermine which service the client should be referred to, but with this current method, it does select the appopioate variable but then types back all the variables not used as it is part of a text card. I kinda need to deploy this asap so any help would be really appreciated! I am sure there is a simple fix, I am just still learning!

https://cdn.discordapp.com/attachments/1131864480607916104/1131864480805040189/screencapture-studio-botpress-cloud-c9249635-c2cc-4456-931b-517f9fb6f101-flows-wf-main-2023-07-21-09_10_28.png

a
Hey @square-beach-57324, you could use a short bit of code to drop the empty variables and keep the ones that have a value in them.
Copy code
js
const variables = [workflow.forPhisio, workflow.forCounselling,... ]; //Put all your vars here

// Use lodash to filter non-blank variables and append them to a new variable
const finalMsg = _.reduce(variables, (acc, val) => {
  if (_.trim(val) !== '') {
    acc += val + ' ';
  }
  return acc;
}, '');

workflow.finalMsg = finalMsg.trim();
Then instead of putting all your vars in the text card, you can just put
@finalMsg
instead
s
Hey man, only seeing this now as I have spent a few days with family. Thank you v much!