Rasa form: how to do recommend web links?

Hi,

My target is to build simple form bot which ask user a multiple competence questions and those ones which user don’t have competence, system should mark those and then, after test, output course links for those weak areas. i.e. if user has 4 weak points there are 4 links, each question has own link

I have done the bot part end form works well but I don’t know how to get this kind of output?

I get list of answers with this boolean function

def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]: return { “kysymys1”: [ self.from_intent(intent=“juu_vastaus”, value=True), self.from_intent(intent=“ei_vastaus”, value=False),

Hi InnoOmnia, welcome to the Rasa community!

You can add a slot value to an utterance by adding the name of the slot in curly braces. So you’d add an utterance in your domain file:

utter_slot_value:

  • text: The value of the slot is {slot_name}

And then you can use it in your stories like any other utterance.

Hope that helps!

Thank you answer,

unfortunately it is not what I looking for. Here is example:

  1. Can you program Java (yes/no) ->yes
  2. Can you program C# (yes/no) -> no
  3. Can you program Python (yes/no) ->no
  4. Can you program C++ (yes/no) ->yes

“hello, here are links for programming languages you need to practice”

www.programming_C#

www.programming_python

So questions 2 and 3 got “no” as answer, so those should be outputted with the right links

Is it clearer now?

Ah, gotcha! In that case I’d probably handle this in an action. With the SDK you can check the value of a slot using tracker.get_slot('slot name'). You can use that to check each of your answers, create a new utterance based on it and then set the slot for a new slot to the text you want tit to be.

So your actions.py file would look something like:

from rasa_sdk import Action
from rasa_sdk.events import SlotSet

class ActionGetCurriculum(Action):
   def name(self) -> Text:
      return "action_check_restaurants"

   def run(self,
           dispatcher: CollectingDispatcher,
           tracker: Tracker,
           domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

      curriculum =  "hello, here are links for programming languages you need to practice:"

      python = tracker.get_slot('python')
      if python == True: 
        curriculum = curriculum + "\n link"

      return [SlotSet("curriculum_slot", curriculum)]

Then you’ll need to run a server for your actions separately. (Also, if you have quite a few questions, a form might save you some time. :))

Hope that helps!

Thanks, I got it working!

1 Like