Hi All,
I would like to display HTTP links(for example: www.http://google.com ) in my chat bot. I’m using latest version of rasa and had written normal rest api.
And i’m training my bot by using commands:
rasa train and rasa run
Can anyone please help me on this.
Ghostvv
(Vladimir Vlasov)
August 28, 2019, 12:15pm
2
could you please elaborate where is the problem? Are the links not displayed?
This is my domain.yml file:
query:
And when i called that in bot, i’m getting result as a plain text for links also.
Output:
[{“recipient_id”:“xyz”,“text”:“You can experience about the services in data2Insights here http://d2imarketing.aadhya-analytics.com/contactus”}]
Ghostvv
(Vladimir Vlasov)
August 28, 2019, 12:49pm
4
sorry, don’t understand what is wrong
This is how links are displaying as plain text in my bot.
Can anyone please help
Ghostvv
(Vladimir Vlasov)
August 29, 2019, 10:48am
6
yes, and how do you want them to be displayed?
In the screenshot http://google.com displayed as plain text. But i want it to highlight in blue color(i.e., as a link), then i can click on that.
I guess it would be done form the front end(UI) side, or i need to do something from the rasa?
Ghostvv
(Vladimir Vlasov)
August 29, 2019, 11:12am
8
highlighting is up to how the front end parses links, so you need to do in your front end
To the front end how can i say that message contains links
For example incase of buttons, message returns with the type buttons and payload. In the same way how can we say that for links
Thank you so much for your reply
Ghostvv
(Vladimir Vlasov)
August 30, 2019, 8:36am
10
the link is just a text anyhow, I guess regex, did you try to search how to do it?
Okay thanks. I will try to do using regex.
Can you copy paste piece of HTML code which you are using to embed bot response in your frontend. Like copy paste entire DIV along with sample HTML.
hey @chinnusujitha , as @Ghostvv suggested you can try out the below regex:
var text=document.getElementById("botMsg").value;
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var text1=text.replace(exp, "<a href='$1'>$1</a>");
var exp2 =/(^|[^\/])(www\.[\S]+(\b|$))/gim;
document.getElementById("msg").innerHTML=text1.replace(exp2, '$1<a target="_blank" href="http://$2">$2</a>');
hope this works out
@JiteshGaikwad Thanks for the answer.