Forum Discussion

BrianBeard42's avatar
BrianBeard42
Copper Contributor
Apr 19, 2022

Saving a Variable and displaying it

This should be an easy answer but I can't find any documentation on it.  I want to be able to prompt the user and receive an answer.  I then want to prompt the user again for another answer and use the variable from the first prompt in my Display Text.  Example:  My first prompt has "What is your name".  I then save that to a variable named varName.  I then go to the second Prompt and I want it to say "Hi, Brian, how are you today?".  I want to take the varName and put it in the Display Text.  How can that be accomplished.  I am fairly new to Healthbot/Chatbot so any help is appreciated.

  • BrianBeard42 In this particular example, you would concatenate the text string and your variable together such as the following;

     

    "Hi" + scenario.varName + "! How are you today?"

     

    This should provide you the results you are looking for.

    • BrianBeard42's avatar
      BrianBeard42
      Copper Contributor
      GregoryLisiak, thanks for the response. I was able to figure it out the other day and it is exactly what you posted.

Resources