How to print dynamic hyperlink in rasa X?

hey, I am struggling to give hyperlinks to users on rasa x.

in my action.py file image

domin.yml

image

Output:

image

link is not clickable. It is a normal string. i want hyperlink as an output.

rasa version - 2.7.10

If can anybody help me to solve this problem? Thank you!

Don’t worry much about formatting in Rasa X (since the developer is the only one using it). You should implement the features you want in your frontend.

Anyway, try to do dispatcher.utter_message(response = "utter_link", attachment = webUrl)

And in your domain: - text: Here you go -

Look at the Dispatcher documentation for more info.

hey @ChrisRahme …thank you for your quick response.

I did changes as you mentioned. But still, on rasa x, it is not giving a clickable hyperlink. which on click should open in a new tab.

action.py image

domin.py image

output image

and I am not focusing on formatting. I just need a clickable hyperlink. On click, a link should open in a new tab.

Thank you!

What I meant is you can make it clickable when you build your your frontend

@tanayraj Try this and It will solve your issue:

utter_link:
- text: " [Here you go](https://rasa.com)" 

Even, if this work you can even render the link whilst storing. I had personally used in my action.py

Proof, in below thread :slight_smile: Good Luck!

1 Like

Good idea, @nik202! I wanted to suggest that, but I wanted to try out if it worked with Rasa X before posting!

If this works in Rasa X (as it does in Webchat), the original utterance should be:

utter_link:
- text: [Here you go]({link})

or, if you want to show the link, maybe:

utter_link:
- text: Here you go - [{link}]({link})

@ChrisRahme Will this will satisfies you :slight_smile: as you suggested I had run and it solved the problem.

1 Like

Great!

@ChrisRahme :wink: :sunglasses:

thank you for your response. But I want to add a dynamic link. In my case, the link is generating from action.py and the link is different each time.

I get it what you have mentioned but I believe it is only useful for a static link.

but thank you once again. if you have any suggestions for dynamic then please share them. i am still stuck at this point.

@tanayraj I guess you not got our point, you can write a code for dynamic link storing and render in domain.yml see the example of Chris.

@tanayraj I am using 100+ dynamic link based on user question. Every time it will be different based on user query.

@tanayraj you also mentioned “I just need a clickable hyperlink. On click, a link should open in a new tab.” that solving you’re issue and for dynamic we already suggested.:slight_smile:

1 Like

@tanayraj

dispatcher.utter_message(template="utter_link", tracker, link=webUrl)

utter_link:
- text: [Here you go] ({link})

You need to try first.

Hope this will solve your issue.

2 Likes

yes, you were right. i just misunderstood. Thank you @nik202 and @ChrisRahme. after using your suggestions it is working as I expected. now I am able to open the link in a new tab.

Thank you once again.

1 Like

Doesn’t work for me, I’m getting a .yaml error when i tried this:

"The provided yaml file is invalid. You can use http://www.yamllint.com/ to validate the yaml syntax of your file."

Can’t reveal much else as of NDA, but I’m trying to print a hyperlink to webchat.

@chris.chu your some file is not properly formatted, do check with yml checker http://www.yamllint.com