How to select specific variable to reply to the user with
# 🤝help


07/21/2023, 8:25 AM
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!



07/21/2023, 12:27 PM
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
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


07/25/2023, 6:52 AM
Hey man, only seeing this now as I have spent a few days with family. Thank you v much!