Calling javascript from Bubble

Hi
I’m trying to add some JavaScript to copy some OpenAI generated text and an image to the clipboard in a free tool we’ve created to help people create social media content (at https://aitools.aiaas.team/ if you’re interested)
I’m using the Toolkit plugin with a Run JavaScript action when the icon is clicked but I get this error


The code is very simple (below) with the data being written to the clipboard coming from a dynamic custom state
Screenshot 2024-04-05 at 10.18.35
What am I doing wrong?!?
I’m sure it’s just me being dumb…any help is really appreciated :slight_smile:

What does the response look like?

It’s the text from ChatGPT …to see it please type something into the box and hit “Create Draft” at https://aitools.aiaas.team/

Okay it may be simpler than you thought. Remove the quotes from your script.

Tried that thanks


got this

Have you used :formatted as JSON safe?

Use that method without quotes.

1 Like

Thanks for looking at it…I’ll try that

If you are copying something to clipboard, try this solution as well. It can copy more complex html into the clipboard.

Interesting. That works the same way as other copy to clipboard plugins or differently?

I don’t know the plugins in the area. I am assuming it should work the same. There are not many different ways to copy to clipboard I guess :slight_smile:

Thanks I’ll look at that as well

Just to let you know that your suggestion worked thanks @GH5T :pray:t2:
This works fine…

1 Like