Closed kapriman closed 3 years ago
Could you please let me know how to add HTML as the bot response in this widget?
I have created html_attachment file, similar to pdf_attachment file, and modified the code wherever required. But I'm not getting any response.
For reference:
domain.yml
responses: utter_html: - text: "Here is the HTML link." custom: payload: html_attachment title: "HTML Title" url: "URL to HTML link"
actions.py
data = { "payload":"html_attachment", "title": "HTML Title", "url": "URL to HTML link" } dispatcher.utter_message(json_message=data)
Also, created a file html_link.js:
/**
@param {Object} html_data json object */ function renderhtmllink(html_data) { const { url: html_url } = html_data.custom; const { title: html_title } = html_data.custom; const html_attachment = <div class="html_attachment"><div class="row"><div class="col s3 html_icon"> <i class="fa fa-file-pdf-o" aria-hidden="true"></i></div><div class="col s9 html_link"><a href="${html_url}" target="_blank"> ${html_title} </a></div></div></div>;
<div class="html_attachment"><div class="row"><div class="col s3 html_icon"> <i class="fa fa-file-pdf-o" aria-hidden="true"></i></div><div class="col s9 html_link"><a href="${html_url}" target="_blank"> ${html_title} </a></div></div></div>
$(".chats").append(html_attachment); scrollToBottomOfResults(); }
Added the above changes in chat.js as well:
Please let me know if i am missing anything here. Appreciate your help. Thanks in Advance :)
Could you please let me know how to add HTML as the bot response in this widget?
I have created html_attachment file, similar to pdf_attachment file, and modified the code wherever required. But I'm not getting any response.
For reference:
HTML Attachment
domain.yml
actions.py
Also, created a file html_link.js:
/**
@param {Object} html_data json object */ function renderhtmllink(html_data) { const { url: html_url } = html_data.custom; const { title: html_title } = html_data.custom; const html_attachment =
<div class="html_attachment"><div class="row"><div class="col s3 html_icon"> <i class="fa fa-file-pdf-o" aria-hidden="true"></i></div><div class="col s9 html_link"><a href="${html_url}" target="_blank"> ${html_title} </a></div></div></div>
;$(".chats").append(html_attachment); scrollToBottomOfResults(); }
Added the above changes in chat.js as well:
// check if the custom payload type is "html_attachment" if (payload === "html_attachment") { renderhtmllink(response[i]); return;
Please let me know if i am missing anything here. Appreciate your help. Thanks in Advance :)