Set attribute

Image of an author
Sylwia Kocur
4 min read
updated: Aug 2, 2022

ChatBot offers several ways to collect information. The easiest way is to use the Question action. It automatically saves the user’s answer so you can use saved data in an ongoing conversation. 

However, sometimes you do not need to ask a question and save it as an attribute. You just need to bring the attribute’s value to the story. That’s when the Set attribute action comes in handy.

Learn more about attributes in the following articles:

When to use the Set attribute actionLink icon

Attributes let you collect common data such as a user’s name or email. Using default attributes, you can also gather more advanced information, including your user’s location or country.

In each of these situations, the Set attribute action can help. This action allows you to save, use, and modify an attribute if needed. 

The Set attribute consists of two elements:

  • SET -  choose the attribute’s name,

  • TO - provide value to the attribute.

chatbot set attribute action

How to use the Set attribute action in your StoryLink icon

Choose the Set attribute block from the Actions and interactions menu and add it to your Story.

Alternatively, you can add a new block directly on the tree by clicking on the plus icon.
Alternatively, you can add a new block directly on the tree by clicking on the plus icon.

How does the Set attribute work with default attributesLink icon

After you add the action to your tree, you need to enter the attribute’s name and value.

When the user provides the correct keywords, your chatbot will recognize the phrases and correctly set the attribute’s value. The chatbot chooses the path based on the Confidence score.

  1. Add the User input block after your Welcome message.

  2. Click on the new block and provide the phrases.

  3. Add the Set attribute action.

  4. Set the Set attribute action to Language.

  5. Provide English as the value. The chatbot can follow this path if the keywords are correct.

  6. Place the second User input and provide the keywords.

  7. Place the second action in your Story.

  8. Set the attribute to Language and provide Polish as the value.

  9. Provide the messages in both languages. Add the responses to the Bot responses block placed after the actions.

  10. Test the Story in the Testing tool - the chat window provided in the visual builder.

    Provide the phrase in Polish. The bot will choose the path that leads to the Polish options. 

You can enable the Debug mode using the 3 dots symbol at the top of the testing tool to see when the bot sets the attribute.
You can enable the Debug mode using the 3 dots symbol at the top of the testing tool to see when the bot sets the attribute.

How to set the value of a custom attributeLink icon

You can add a custom attribute if you want to use more advanced information that doesn’t qualify as a default attribute. Add this attribute while setting the Set attribute action.

  1. Click on the Set attribute block. 

  2. Click on the + Add custom attribute option at the bottom of the menu. This will open a pop-up window.

  3. Provide the name of your custom attribute and save it.

  4. The custom attribute is now visible in the menu with the default attributes.

  5. Add the User input block. Click on it and add your newly created attribute. Use the brackets symbol. Your bot needs a place to collect the attribute.

  6. You can use the custom attribute the same way as the default attributes.

  7. Add a Bot response block to continue the chat.

The difference between Question and Set attribute actionsLink icon

ChatBot allows you to collect information in several ways. The easiest way is to use attributes. You can collect them using the Question or Set attribute action. 

While using the Set attribute action, you must create and collect the attributes in separate steps. In contrast, Question allows you to do it in just one step as you create and collect the attribute in the same place in the Story.

Like the Set attribute action, the attributes contained using the Question action can be saved, used, and modified throughout the Story. Also, it lets you ask multiple questions. Each answer is also saved automatically as an attribute. 

The Set attribute action lets you keep only one attribute at a time. While the Question action is more efficient, sometimes you do not need to ask a question; you just need to set an attribute’s value in the story. In such cases, the Set attributes action is more beneficial.

Attributes in the ArchivesLink icon

After the chat, all of the attributes are available in the Archives. You can check them there and analyze the chat information.

Was this article helpful?

Got it!

Thanks for your feedback.

Thank you!

We’re happy to help.

Start a free ChatBot trial
and build your first chatbot today!

Free 14-day trial No credit card required

Discover our text| products