【问题标题】:How do I utter dynamic message with hyperlink attached in Rasa X?如何在 Rasa X 中发出带有超链接的动态消息?
【发布时间】:2021-06-16 06:38:59
【问题描述】:

如何发出消息、根据数据表显示结果并在文本中附加超链接?
我想要实现的示例:

    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)

格式化方法:

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


我遇到的问题是 Rasa X 使用正确的数据显示字符串,但超链接未附加到电话号码。

【问题讨论】:

    标签: python hyperlink custom-action rasa rasa-x


    【解决方案1】:

    不同平台的前端显示链接不同。 Rasa X 使用 Markdown 格式显示链接。

    所以,你需要使用 Markdown 链接格式来代替普通的锚标签来显示。

    改变

    hypNum = '<a href="tel:%s">%s</a>' % (n, formatNum)
    

    到这里

    hypNum = '[%s](tel:%s)' % (formatNum,n)
    

    希望这能解决您的问题。

    【讨论】:

    • 太棒了,这行得通。我没有足够的分数来支持答案,所以在那之前我只能写 cmets。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-19
    • 1970-01-01
    • 1970-01-01
    • 2020-05-06
    • 2022-08-02
    • 1970-01-01
    • 2020-10-19
    相关资源
    最近更新 更多