Step 4: Add the username placeholder chip

So far, we've created a variable to store the user's name, a passage that prompts the user for their name, and stored their response as the variable's value. Now let's use that variable in our chatbot content to address our user by name.

Variables can be used almost anywhere in your chatbot content by adding variable placeholder chips. To add a variable, type the @ key and choose the variable you want to use. Before it sends this passage to the user, the chatbot replaces the placeholder chip with the value of the variable.

Let's address our user by name:

  1. Open the new passage created by the Send Info response.
  2. Rename the passage to Greet user by name.
  3. In the text message, type a greeting to the user.
    To use the Username variable to display their name, type @ and choose the Username variable.
  4. Click Save.

We're all done! Now our chatbot will ask the user their name, save their reply to our Username variable, and use that value in the next passage to address them by name. The value will be available in any passage for the rest of the conversation with that user. 

When writing content with variables, remember that the variable value will be the default value (or blank, if you haven't set a default) until a value is saved by an action during the conversation. If the user reach this second passage without the Username variable being set, the chatbot will use the default value we set of 'friend'. 

It's good practice to check whether a user can reach your passage without the variable being set. If they can, then either add a default value to your variable, or write your chatbot content so that it it will still seem natural if the value is blank.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.