Skip to content

Articulate Storyline (JavaScript)

With this destination, the screen is a Storyline slide, and the integration code connects it to SlideMind through Storyline variables. For a Q&A or a Chat, SlideMind gives you a ready-made Storyline slide to import into your project. You can also build the screen yourself and paste the code in an Execute JavaScript trigger. This page is for Storyline authors. Status: stable.

Choose this destination when you want your own layout, triggers that branch on the AI’s results, values sent from Storyline to the prompt, or a Capture slide. If you prefer a ready-made chat panel that shows the whole conversation, use Articulate Storyline (Web Object) instead.

Video tutorial, Ep. 2: Your first AI Q&A slide. A Q&A slide tested in Try it, published, then imported into Storyline from its .story file. Steps and texts to copy on SlideMind Academy ↗
  • In the slide editor, the Activity box shows Storyline with the tool’s own fields. If not, select Change and choose Authoring tool, then Articulate Storyline.
  • The slide is published. The Installation step shows This slide is not published yet until it is.
  • Your workspace has AI connected and your allowed websites are set. See Integration overview.

For a Q&A or a Chat, the Installation step is titled “Add it to Storyline”. It opens on the Ready-made Storyline slide card, followed by two closed sections: Manual setup and Storyline variables. A Capture slide keeps the setup steps and Copy the code (see Capture slides).

The ready-made slide is a Storyline slide built for your SlideMind slide. It holds the Storyline variables with their names, a text entry field for the learner, a button whose Execute JavaScript trigger carries the integration code, a text box for the reply, and a loading layer shown while the AI answers. Its title and labels are in the slide’s learner language.

  1. In the Installation step, select Download the slide (.story). If the slide has unsaved changes, the button reads Save & download the slide and saves the slide first. The file is built from the saved slide.
  2. In your Storyline project, import the slide with File › Import › Storyline, or open the downloaded file in Storyline and copy-paste the slide into your project.
  3. If Storyline asks what to do with variables that already exist, choose Merge. This happens when you import the same slide again.
  4. Publish the course to the web or to your LMS to test it. Storyline does not run JavaScript triggers in Preview.

What the learner reads first:

  • Q&A. The question you typed in SlideMind. The slide shows it through the …_question variable, which only the ready-made slide uses.
  • Chat. The Opening message of the Conversation step. SlideMind also sends it to the AI, so it knows what the learner read. See Conversations (Chat).

When the Chat has a turn limit at download time, the ready-made slide also shows a turn counter, such as “2/4”, under the message box. If you add a limit later, download the slide again, or type the counter yourself (see Chat slides).

You can restyle the slide and move its objects, like any Storyline slide. Keep the variable references in the text boxes and the trigger of the button.

If the download fails with “The Storyline slide could not be built”, use Manual setup instead, then try the download again later.

Open Manual setup to build the screen yourself. It lists the setup steps, then Copy the code and Show the code:

  1. In Storyline, create two text variables named after the question and answer variables, for example userMsg_s2_practiceRolePlayA and aiResp_s2_practiceRolePlayA.
  2. Add a text entry field for the learner and store what they type in the question variable.
  3. Add a button with an Execute JavaScript trigger (when the user clicks), then paste the code from Copy the code.
  4. Show the reply in a text box by inserting the answer variable between percent signs, for example %aiResp_s2_practiceRolePlayA%.
  5. Publish the course to the web or to your LMS to test it. Storyline does not run JavaScript triggers in Preview.

The names in the steps are shown as they must be pasted in Storyline, percent signs included in step 4. Click a name to copy it.

For a Chat, also create the _history and _done variables before you copy the code. For a Q&A, the question you type in SlideMind is sent to the AI with each answer. Keep it identical to the question on your Storyline screen.

The code is built for your slide and its variable names. A shortened Q&A example:

// === SlideMind Integration: Practice: Role-Play a Feedback Session (qa) ===
var player = GetPlayer();
var configUid = "abc123";
var baseUrl = "https://…/api/v1";
// … learner detection (sm_user, SCORM, xAPI, cmi5) …
var learnerId = detectLearner(null);
var userMessage = player.GetVar("userMsg_s2_practiceRolePlayA");
// … sends the message to SlideMind, retries quietly when the service is busy …
player.SetVar("aiResp_s2_practiceRolePlayA", data.message.content);

Paste the whole code as it is. When a learner clicks the button, the code reads the question variable, identifies the learner when the course runs in an LMS, sends the message to SlideMind with any values from Storyline, and writes the reply into the answer variable. When the service is busy, the code waits and tries again a few times on its own before it reports an error.

A second click while the AI is answering sends nothing. A request that never gets an answer ends after a time limit: _busy returns to false and the error variable explains the failure.

The Storyline variables section of the Installation step lists the exact names. The ready-made slide already holds them. If you build the screen yourself, create each Storyline variable with exactly that name: same spelling, same case. The copy button beside each name copies it, ready to paste in Storyline.

VariableStoryline typeWhen you need itWhat it holds
Question variable, for example userMsg_s2_practiceRolePlayA (Learner question)TextQ&A and ChatWhat the learner typed. The code reads it.
Answer variable, for example aiResp_s2_practiceRolePlayA (AI answer)TextQ&A and ChatThe AI’s reply. With structured results, the text of one Text field (see Use the structured results).
Answer variable + _busy (AI answering (true/false, for a loading layer))True/FalseOptionaltrue while the AI answers. Use it to show a loading layer.
Answer variable + _err (Error variable)TextOptional, recommendedA message when the call fails or a result is incomplete.
Answer variable + _json (Structured JSON)TextOptional, with structured resultsThe whole result, as JSON.
Answer variable + _ + field name, for example aiResp_s2_practiceRolePlayA_score (Return field)Number, True/False or Text, to match the fieldWith structured resultsOne field of the result.
Answer variable + _history (Conversation history (text))TextChatThe conversation so far.
Answer variable + _done (Conversation ended (true/false))True/FalseChattrue once the learner has used the last turn allowed.
Answer variable + _turns (Turns answered (number))NumberChat, optionalThe learner turns that got a reply. A failed request doesn’t count.
Answer variable + _max_turns (Turn limit (number, 0 when unlimited))NumberChat, optionalThe slide’s turn limit, or 0 without a limit.
Each value under Values from Storyline, for example learner_roleThe type you already useWhen the slide lists such valuesA value the code reads and sends with the message.

The section lists _json, _err and the return fields only when the slide has structured results. The error variable is useful on any slide, though: the code also writes to it when a call fails.

Until you rename them, the question and answer names come from the slide number and title. SlideMind adds userMsg_ or aiResp_, then s and the slide number, then the title shortened to a few words in camelCase. A slide numbered 2 and titled “Practice: Role-Play a Feedback Session” gives userMsg_s2_practiceRolePlayA and aiResp_s2_practiceRolePlayA. Without a slide number, the s2_ part is left out. You set the number in Slide details, under Slide number.

Every other name starts with the answer variable. These names keep each slide’s variables apart, so several SlideMind slides can share one Storyline project.

To use your own names, edit the question and answer names in Storyline variables before you download the slide or copy the code:

  • Names use letters, digits and underscores only, and cannot start with a digit (64 characters at most).
  • The copy button beside each name copies it, ready to paste in Storyline.
  • The reset button returns to the generated name.

The code keeps the conversation in the _history variable and sends it with every message, so the AI remembers earlier turns. Each click on your button sends one learner message.

  • Opening message. SlideMind sends it to the AI at the head of the conversation. The ready-made slide opens on it. If you build the screen yourself, show the same text on your Storyline screen.
  • Turn limit. After the last turn allowed by the slide, the code sets _done to true and sends nothing more. The limit is written into the code: if you change it in SlideMind, install the code again.
  • No limit. When the slide’s turn limit is 0 (no limit), _done stays false.
  • Turn counter. The code writes _turns and _max_turns when a message is sent, then adds 1 to _turns after each successful reply. To show “2/4” under the message box, insert %aiResp_s2_practiceRolePlayA_turns%/%aiResp_s2_practiceRolePlayA_max_turns% in a text box, with your own variable names. Code installed before October 26, 2026 doesn’t write them: install it again.
  • Empty message. If the question variable is empty, the code sends nothing.
  • Start over. Set the _history variable to an empty text, for example with a “Restart” button.

The slide shows the last reply. To show the whole conversation as it unfolds, choose the Articulate Storyline (Web Object) destination. To read the conversation on a later slide, keep it with Remember for later slides (conversation memory), then load it on that slide through the Memory Hub. See Saving values.

To make the Next button wait for the end of the conversation, add a trigger that changes the state of Next when the _done variable changes. This needs a turn limit: without one, _done never turns true.

When the slide returns structured results (Structured JSON in the What comes back? step), the code writes each field into its own Storyline variable, named after the answer variable: aiResp_s2_practiceRolePlayA_score, aiResp_s2_practiceRolePlayA_passed, and so on. Use them in your triggers: branch to another slide when the _passed variable is true, or send the score to your LMS.

The answer variable receives the text of one Text field, never the raw JSON. With several Text fields, choose it in Field sent to the reply variable (Shown to the learner for a Chat) in the What comes back? step. Without any Text field, the answer variable stays empty and only the field variables are filled: the step warns you.

The fields are written only when the AI returns every field correctly. Otherwise, the return variables keep their previous values, so a learner never gets an invented score, and the error variable receives assessment unavailable: followed by the missing fields. The answer variable stays empty when the text it receives is missing. The _json variable holds the whole result either way. See Results: plain text or structured.

When a call fails, the code writes SlideMind error ( followed by a status number and ) into the _err variable, for example SlideMind error (403). What each number usually means is listed in Test before going live.

The code empties this variable each time it sends a message, so an earlier error never stays on screen.

A Capture slide saves values from Storyline into the learner’s memory, without calling the AI. In Storyline it always uses this JavaScript destination, never the Web Object.

  1. In Storyline, make sure the variables this slide captures exist, with exactly the same names.
  2. Run the code from Copy the code in an Execute JavaScript trigger at the moment those values are known, for example when the learner clicks Continue.
  3. Test it in the published course launched from your LMS. Only an LMS identifies the learner, and Storyline Preview does not run the code.

A capture shows nothing to the learner, even when it fails. When no learner is identified, the code stops and nothing is saved. See Saving values.

The Try it panel of a Storyline slide, listing the Storyline variables after the reply: the answer variable with the feedback text and the feedback field named on the same row, then the score field under its prefixed name

  • Preview does not run Execute JavaScript triggers. Publish the course.
  • Publishing to the web runs the code, but usually no learner is identified: the AI answers, and learner memory stays off.
  • Review 360 and share links never identify the learner either.
  • To test learner memory, launch the course from your LMS or from SCORM Cloud.

See Test before going live for the full checklist.