https://discord.gg/botpress logo
Turning a response into a downloadable document or...
# 🤝help
h
Hey all I have a bot which ends with creating a newsletter for the user. Its ~1000 words. I want the user to be able to be able to easily copy the text and get it into a document on their computer. Some things I have tried/thought about; - Having a 'copy to clipboard' button native in the chat. I've searched for this and doesn't seem to exist. I found a few threads here in Discord, one from 2023 asking for this feature, but its not currently supported. A little surprising since it seems like such a common feature for chat bots like this - Looking for a card which creates a file from content - Again couldn't find this, or any references to it. - Trying to send a custom event from the chat bot to my website and then doing the copy to clipboard myself. I was able to get custom events working (it is very particular RE the format of the JSON its expecting to be pasted into the field - would be nice to include an example in the docs or something). However when I then try and send all my generated text through the custom event it fails. Presumable because its not correctly formatted as JSON and includes quotes etc. I'm going to try and use a custom action to encode the JSON and then pass it back and use that as the custom message, but yeah, feels a bit hacky. Am I missing somehting obvious/easy? Any help would be greatly appreciated!
n
The most easiest thing u can do is to add a card and attach downloadable document link , this can be only done if the document persist in every situation, of not u have to align this method accordingly
h
@limited-pencil-78283 thanks so much for the suggestion. The UX of getting a text file and selecting it all and copying it to a clip board to be able to paste into a word doc or something is not great. But could you please send me the code you're using in the code block to do the upload? Having trouble getting the right syntax? I'm also playing with using the code card to send a custom event myself. This is what I have (attached) but its erroring, presumably because there isn't a conversationId? I coudln't find a way in the code block to the get current conversation ID?
here you go
current conversationId will be available in event.conversationId
I did not add the code to get conversationId for this bot as it was not required
h
@limited-pencil-78283 thanks, I'll give that a try. I'd muchhhh prefer to be able to send the custom event to my app, instead of the file situation. I've trying to use the code card to send an event, but I just get an error. Attached is the code I have. https://cdn.discordapp.com/attachments/1378588953078267985/1379005983040475176/image.png?ex=683eaae7&is=683d5967&hm=b3d966f9884d83c98e2b89aefdfd7fcebe37ef737cf157bae3927a360c550ffb&
Is there any way to see a log of these errors? Since events don't seem to run inside the emulator I can't see what error its throwing.
l
if you could explain the workflow, i could help you better
in the conde above before return statement you can add console.log("Event : ", customEvent) and it display the contents in customEvent in logs for emulator logs are displayed in logs section towards the bottom of the studio for publish logs, you can see the logs in the dashboard -> logs
p
Hi, You are absolutely welcome to bring up the copy to clipboard feature again in the https://discord.com/channels/1108396290624213082/1111026806254993459 channel, as I don't think input from 2023 is considered these days, since the product has changed a lot. You mentioned you would like to see an example of a json snippet somewhere in the docs, could you elaborate exactly where you feel the information is missing. I'm happy to relay the information to my coworker, however there is also a channel for that: https://discord.com/channels/1108396290624213082/1356320776671989937
w
there is an integration called HTML to pdf or Markdown to pdf or something like this that allows you to create a file and then using the url generated (using botpress files) to present them to the user as a file
h
Hey @wooden-beard-40210 thanks for the suggestion, but in the end I want my users to be able to copy the text/html/markdown into a format/document of their choice. So having to get them to download a PDF, open it, select all the text, copy it and then finally paste it into their desired format/program isn't going to be good enough. If there was an extension into DOCX then that would probably be enough.
Thanks @prehistoric-airplane-85682 I've made a comment on a post from 2024 regarding that. Interestingly another user independently has just commented on it a few days ago asking the same thing. Do you think its worth creating a new thread (even though it just says the same thing)? And I've added a comment in the docs feedback, thank you.