How do I utter a message, displaying results based on a datasheet, and attach a hyperlink within the text?
Example of what I am trying to achieve:
num = phone_format(str(sheet["" + chr(ord(requested_info_column)+1) + "{}".format(row)].value))
dispatcher.utter_message(text="The " + column_names[requested_info_column]
+ " for the " + str(sheet["B{}".format(row)].value) + " project is "
+ str(sheet["" + str(requested_info_column) + "{}".format(row)].value)
+ " and can be reached at " + num)
formatting method:
def phone_format(n):
formatNum = '({}){}-{}'.format(n[0:3], n[3:6], n[6:])
hypNum = '<a href="tel:%s">%s</a>' % (n, formatNum)
return hypNum
The issue I am having is that Rasa X displays the string, with the correct data, but the hyperlink is not attached to the phone number.
Displaying links in the front end is different for different platforms. Rasa X uses Markdown Format to display the links.
So, instead of the normal anchor tag, you need to use Markdown link format for display.
Change
hypNum = '<a href="tel:%s">%s</a>' % (n, formatNum)
to this
hypNum = '[%s](tel:%s)' % (formatNum,n)
Hope this solves your issue.