We have the capability to assign attributes to a user as they chat with a bot. This is useful to store information about the user. For example, if we want to store the user's email, or if we want to store the user's favourite flavor of ice cream.
Let's go to the "you just said hello" story change the first text response to
text: What is your favorite flavor of ice cream?
then let's add a memory response
ACTION
type: memory
property: asked-fav-icecream
function: set to
value: true
CHAT
User: hello there
Bot: hey!
Bot: (secretly, without telling the user, sets *said-hey* to true in the session)
User: how are you?
Bot: (saw that the property said-hey equals true in the user's chat session)
Bot: What is your favorite flavor of ice cream?
and let's assign this to a new story called "entered fav ice cream"
Go to the "entered fav ice cream" story and add a new action response
type: user attribute
property: fav_ice_cream
function: set to
value: {{message.text}}
then add yet another text response
message: I love {{user.fav_ice_cream}} too! It's amazing.
We just used a merge tag called fav_ice_cream to refer to the new user attribute. Now the chat flows as follows:
User: hello there
Bot: hey!
Bot: (secretly, without telling the user, sets *said-hey* to true in the session)
User: how are you?
Bot: (saw that the property said-hey equals true in the user's chat session)
Bot: What is your favorite flavor of ice cream?
Bot: (secretly, without telling the user, sets *asked-fav-icecream* to true in the session)
User: chocolate
Bot: (saw that the property asked-fav-icecream equals true in the session)
Bot: (store's the user's last message to an attribute called fav_ice_cream)
Bot: I love chocolate too! It's amazing.
Now, refer to the user's favorite ice cream with the merge tag {{user.fav_ice_cream}} in any of our responses or cards REGARDLESS of the chat session.
The user will start chatting with the bot again tomorrow (theirfav_ice_cream will still be chocolate).