Forum Discussion

RichardDettl457's avatar
RichardDettl457
Community Member
11 days ago
Solved

Assistance Needed: Enabling Easy Copy & Paste for ChatGPT-Generated Vision Statements in Storyline

I created a slide using a ChatGPT-generated response where users input their name, role, goals, and future position. After clicking "Submit," ChatGPT generates a personalized Vision Statement for them. I want users to be able to copy this Vision Statement easily and paste it into a Word document. Is this possible? If so, can someone guide me on how to set this up using JavaScript?

  • SamHill, I can’t thank you enough for this! Your JavaScript and detailed directions worked like a charm. As someone with no prior JS experience, I was still able to follow your instructions and get everything working. It did take me about an hour to locate the container since I had to expand all the JS, but persistence definitely paid off!

    This whole process has actually inspired me to consider taking a Java course so I can write my own scripts in the future. But for now, I’m just incredibly grateful for your guidance. Thanks again! 🙌

  • Hi RichardDettl457 this is possible to do, but the challenge is identifying the containers that contain the text that you would like to copy. For example, the vision statement text is within a HTML container. In order to get the text from it, we must be able to select the container using JavaScript. You can do this by finding the "id" attribute of the container that begins with "acc-". You can find the "id" by publishing the course, and then using your browser developers tools to inspect the HTML, and find the container that contains the vision statement. You will probably find there are two containers that contain the text from the vision statement. The one we want has an id that begins with "acc-".

    Here's the JavaScript anyway. Execute this JavaScript on timeline start trigger (or a Master Slide if used on multiple slides).

    // Add this function to the window object to make it globally accessible
    window.copyVisionsStatement = function ($id) {
        const text = document.getElementById($id).innerText; // Get text content
        navigator.clipboard.writeText(text).then(() => {
            alert("Text copied to clipboard!");
        }).catch(err => {
            console.error("Error copying text: ", err);
        });
    }

    Then, you will call the function by executing the following JavaScript on the click trigger. You will need to find the ID of the container. You can do this by publishing the content, and then using the 

    // Pass the ID value to the copyVisionsStatement function.
    window.copyVisionsStatement("acc-6UbXcV1oEmo");

    I've attached an example of implementation.

    • RichardDettl457's avatar
      RichardDettl457
      Community Member

      SamHill, I can’t thank you enough for this! Your JavaScript and detailed directions worked like a charm. As someone with no prior JS experience, I was still able to follow your instructions and get everything working. It did take me about an hour to locate the container since I had to expand all the JS, but persistence definitely paid off!

      This whole process has actually inspired me to consider taking a Java course so I can write my own scripts in the future. But for now, I’m just incredibly grateful for your guidance. Thanks again! 🙌