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.
Before you start
Section titled “Before you start”- 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).
Add the ready-made slide
Section titled “Add the ready-made slide”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.
- 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.
- 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.
- If Storyline asks what to do with variables that already exist, choose Merge. This happens when you import the same slide again.
- 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
…_questionvariable, 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.
Build the screen yourself
Section titled “Build the screen yourself”Open Manual setup to build the screen yourself. It lists the setup steps, then Copy the code and Show the code:
- In Storyline, create two text variables named after the question and answer variables, for example
userMsg_s2_practiceRolePlayAandaiResp_s2_practiceRolePlayA. - Add a text entry field for the learner and store what they type in the question variable.
- Add a button with an Execute JavaScript trigger (when the user clicks), then paste the code from Copy the code.
- Show the reply in a text box by inserting the answer variable between percent signs, for example
%aiResp_s2_practiceRolePlayA%. - 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.
What the code looks like
Section titled “What the code looks like”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.
Storyline variables
Section titled “Storyline variables”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.
| Variable | Storyline type | When you need it | What it holds |
|---|---|---|---|
Question variable, for example userMsg_s2_practiceRolePlayA (Learner question) | Text | Q&A and Chat | What the learner typed. The code reads it. |
Answer variable, for example aiResp_s2_practiceRolePlayA (AI answer) | Text | Q&A and Chat | The 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/False | Optional | true while the AI answers. Use it to show a loading layer. |
Answer variable + _err (Error variable) | Text | Optional, recommended | A message when the call fails or a result is incomplete. |
Answer variable + _json (Structured JSON) | Text | Optional, with structured results | The whole result, as JSON. |
Answer variable + _ + field name, for example aiResp_s2_practiceRolePlayA_score (Return field) | Number, True/False or Text, to match the field | With structured results | One field of the result. |
Answer variable + _history (Conversation history (text)) | Text | Chat | The conversation so far. |
Answer variable + _done (Conversation ended (true/false)) | True/False | Chat | true once the learner has used the last turn allowed. |
Answer variable + _turns (Turns answered (number)) | Number | Chat, optional | The learner turns that got a reply. A failed request doesn’t count. |
Answer variable + _max_turns (Turn limit (number, 0 when unlimited)) | Number | Chat, optional | The slide’s turn limit, or 0 without a limit. |
Each value under Values from Storyline, for example learner_role | The type you already use | When the slide lists such values | A 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.
How the names are built
Section titled “How the names are built”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.
Rename the variables
Section titled “Rename the variables”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.
Chat slides
Section titled “Chat slides”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
_donetotrueand 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),
_donestaysfalse. - Turn counter. The code writes
_turnsand_max_turnswhen a message is sent, then adds 1 to_turnsafter 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
_historyvariable 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.
Use the structured results
Section titled “Use the structured results”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.
The error variable
Section titled “The error variable”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.
Capture slides
Section titled “Capture slides”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.
- In Storyline, make sure the variables this slide captures exist, with exactly the same names.
- 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.
- 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.
Test the integration
Section titled “Test the integration”
- 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.