How do i send multiple URLs (present in a list) as a response to the user via a dispatcher?

How do i send multiple URLs (present in a list) as a response to the user via a dispatcher? @nik202

I think you can create custom action to get this list and send it usign JSON and use front-end to read this JSON and insert in messages

Or, you can use Custom Output Payloads

1 Like

Thank you @itsjhonny . I will try to do it using JSON. Also, i would like to know how this problem can be approached using dispatcher.utter_message(attachment = “”)

I had done this way, but it isnt printing all the URLs present in the list, and also, i dont get output in the form of a hyperlink but in a simple text format…

list = ["https://www.example1.com", "https://www.example2.com", "https://www.example3.com"]

for i in range(0, len(list)):
        dispatcher.utter_message(text  ="link", attachment = list[i])

@Meenu1 if you are making the API call first try print the value in action.py and then the same approach used for dispatcher whilst storing that value in the variable or use the f string in python Ref: f-strings in Python - GeeksforGeeks

Tip: print that are you able to get all the links if yes then only print the list in attachment i.e attachment = list

Good Luck!

1 Like

Okay thankyou very much @nik202 .

@Meenu1 no worries and sorry for the late reply as I was busy with my work and the time difference :slight_smile: If you need further help do let me know.

Hi!

I think you can get TimeOut error if your list is too long I think rasa can’t wait many times (maybe more than 5 seconds) to response to user

list = ["https://www.example1.com", "https://www.example2.com", "https://www.example3.com"]
jsonStr = json.dumps(list)

dispatcher.utter_message(text="some text", link_list = jsonStr)

Now, in your front-end, you need to get link_list JSON parameter and make hyperlink configuration

like <a href='https://www.example1.com'> https://www.example1.com </a>

This method prints the link as a text itself

@Meenu1 can you share the code file and the screenshot?

Tip: First try print the https link and check are you able to get the hyperlink working on your frontend or not.

Okay @nik202 , i have tried it. When i just try to print the hyperlink, it isnt printing at all. I am getting a blank output from chatbot

Hi @nik202 , im very sorry for the late reply I have used angular for front end. Why do you think this issue is occuring and why isnt attachment parameter not working?