Search code examples
facebook-messenger-botrasa-nlu

How can I save user preference in messenger bot built by rasa


I have built a bot for facebook messenger using rasa nlu . Initially I am giving user a language select option. I want to save user preference at the first time and later , I do not want to ask user again to set their language preference , how can I do it ?


Solution

  • you can have a seperate slot for your language and save it in that slot. Then your further developments can be done by looking at the language slot value. Slot is like a placeholder in rasa.

    In you domain.py file, you can define the slot like this

    slots:
      language:
        type: text
        initial_value: "en"
    

    Then you can define it as an entity in your same domain.py file like below.

    entities: 
      - language
    

    then you can set your slot value in your stories like below.

    visitor_resp{"language":"english"}
    

    And the your language slot value is set.

    For more details please visit https://rasa.com/docs/rasa/core/slots/