Digital Assistant and Mobile

Get Involved. Join the Conversation.

Topic

    Moblize IT
    Storing data into user or bot session
    Topic posted December 28, 2018 by Moblize IT, tagged Bots, Virtual Assistant 
    75 Views, 1 Comment
    Title:
    Storing data into user or bot session
    Summary:
    Store some session specific data
    Content:

    we have a usecase where bot wants to process a customer order. It is running on FB channel. So, once customer provides the email address we make an API call and check if the customer already exists and fetch his profile data. Most of this data we need it until we reach to the final step of order completion step. 

    The current way we are persisting this data is using 

    conversation.setVariable in the CC and having those variables defined in BotML. 

    The above approach works but not very nice as we had to created a lot of attributes in the BotML to store those profile attributes and we dont really use them in dialog flow. 

    Is there a way we can instead store against some user session and can simply retrieve when needed? This will save us in three things:

    1. declaring those attributes in botML

    2 Passing all those in botML CC call in the final step of create order

    3 Having those as input parameters in the CC definition. 

     

    Please advise

    Version:
    18.2.5

    Comment

     

    • Frank Nimphius

      Hi,

      I would create a custom component, pass the mail address to it, have the component checking for the user profile and have the custom component updating a single context variable of type string with a JSON object. So if the variable name is "botUser", then you could access the information therein as 

      ${botUser.variable.firstName! unknown}

      ${botUser.variable.lastName! unknown}

      ${botUser.variable.address! unknown}

       

      The "! unknown" ensures that if no information is available, that "unknown" is printed instead. Another way to handle the case in which there is a specific attribute not set is

       

      ${botUser.variable.firstName?has_content?then(botUser.variable.firstName, 'unknown')}

       

      Frank