Storyline Interaction Lab

How to Create a Chat Response Simulator in Articulate Storyline or Rise

Learn how to create a chat response simulator in Articulate Storyline or Rise 360 that lets learners practice real-world conversations. This step-by-step tutorial includes complete JavaScript code, customizable scenarios, and platform-specific configuration for both Storyline and Rise.

By Nathan Stoker · Published Jul 12, 2026 · Updated Nov 8, 2026 · 12 min read

How to Create a Chat Response Simulator in Articulate Storyline or Rise

Want to help learners practice real-world conversations without the awkwardness of role-playing with a colleague? A chat response simulator lets learners experience realistic messaging scenarios and choose how to respond—all within the safety of an e-learning course.

This tutorial walks you through building a fully functional chat response simulator in Articulate Storyline. By the end, you'll have an interactive activity where learners read incoming messages, select from multiple response options, and receive immediate feedback on their communication choices.

Why Use a Chat Simulator for Training

Traditional multiple-choice questions feel disconnected from real workplace situations. A chat simulator, on the other hand, mirrors how people actually communicate today. Whether you're training customer service representatives, helping managers handle difficult conversations, or teaching conflict resolution skills, this format creates an immersive learning experience.

The simulator includes several features that enhance engagement. Learners see a realistic chat interface with incoming messages, typing indicators, and timestamps. They choose from multiple response options and watch their selected response appear in the conversation. Immediate feedback explains why their choice was effective or suggests a better approach.

Setting Up Your Storyline Project

Before diving into the JavaScript, you need to set up your Storyline project correctly. Create a new project and add a single slide where your chat simulator will live.

Adding the Web Object

The chat simulator runs inside a web object, which allows Storyline to display custom HTML content. Here's how to add it:

  1. Go to Insert > Web Object

  2. In the dialog that appears, select Web file

  3. Browse to your HTML file (we'll create this in the next section)

  4. Check Load web object automatically

  5. Position and resize the web object to fill your slide

The web object should be large enough to display the chat interface comfortably. A size of approximately 1200 pixels wide by 600 pixels tall works well for most screen sizes.

Creating the Completion Variable (Storyline Only)

If you're using Storyline, you'll need a variable to track when the learner finishes the simulation. This allows Storyline to respond to completion, perhaps by enabling a Next button or showing a completion message.

  1. Open the Variables panel

  2. Click Create a new variable

  3. Name it simulationComplete

  4. Set the type to True/False

  5. Set the initial value to False

If you're using Rise 360, skip this step—Rise handles completion differently through its block settings.

Understanding the Chat Interface Structure

The HTML file creates a complete chat experience with several key components. The interface displays a header showing the contact name and status, a message area where the conversation unfolds, and a panel of response options for the learner to choose from.

The layout uses a two-column design. The left column contains the chat window with its familiar messaging app appearance. The right column displays the response options, feedback panel, and navigation controls. This separation makes it clear where learners should focus their attention at each stage.

The Scenario System

Each scenario in the simulator includes context about the situation, contact information for the person messaging, a series of incoming messages, and multiple response options. One option is marked as the best choice, with feedback explaining why each option works or doesn't work.

Here's how a single scenario is structured in the code:

{
    context: "Customer Support",
    description: "A frustrated customer is complaining about a delayed shipment.",
    contact: { name: "Alex Rivera", status: "Frustrated customer", avatar: "AR" },
    messages: [
        { type: "incoming", text: "This is ridiculous! My package was supposed to arrive THREE days ago!", time: "2:34 PM" },
        { type: "incoming", text: "I've called twice already and gotten nowhere.", time: "2:35 PM" }
    ],
    options: [
        { 
            text: "I completely understand your frustration. Let me track down your package right now.",
            correct: true,
            feedback: "You acknowledged their emotions and moved toward a solution."
        },
        // Additional options...
    ]
}

This structure makes it easy to add new scenarios or modify existing ones without touching the core functionality.

Complete Code

Save the following code as an HTML file. This is the complete chat response simulator that you'll reference in your Storyline web object.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Chat Response Simulator</title>
    <!-- 
    ============================================
    PLATFORM CONFIGURATION
    ============================================
    Set 'platform' to either 'storyline' or 'rise'
    
    For Storyline: Also set your variable name below
    For Rise: No additional configuration needed
    ============================================
    -->
    <script>
        const CONFIG = {
            platform: 'storyline',              // 'storyline' or 'rise'
            storylineVariableName: 'simulationComplete'  // Only used when platform is 'storyline'
        };
    </script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', system-ui, sans-serif;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
            min-height: 100vh;
            color: #fff;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
        }

        header {
            text-align: center;
            margin-bottom: 30px;
        }

        header h1 {
            font-size: 1.8rem;
            margin-bottom: 8px;
            background: linear-gradient(90deg, #00d4ff, #7b2cbf);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        header p {
            color: #8892b0;
            font-size: 0.95rem;
        }

        .scenario-info {
            background: rgba(255,255,255,0.05);
            border-radius: 12px;
            padding: 16px 20px;
            margin-bottom: 20px;
            border-left: 4px solid #7b2cbf;
        }

        .scenario-info h2 {
            font-size: 0.85rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: #7b2cbf;
            margin-bottom: 6px;
        }

        .scenario-info p {
            color: #ccd6f6;
            font-size: 0.95rem;
        }

        .main-layout {
            display: flex;
            gap: 20px;
            height: 500px;
        }

        .chat-window {
            flex: 0 0 360px;
            background: #0f0f1a;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 20px 60px rgba(0,0,0,0.4);
            display: flex;
            flex-direction: column;
            height: 100%;
        }

        .response-panel {
            flex: 1;
            min-width: 0;
            height: 100%;
            overflow-y: auto;
        }

        @media (max-width: 800px) {
            .main-layout {
                flex-direction: column;
                height: auto;
            }
            
            .chat-window {
                flex: none;
                width: 100%;
                height: 350px;
            }

            .response-panel {
                height: auto;
            }
        }

        .chat-header {
            background: linear-gradient(90deg, #7b2cbf, #00d4ff);
            padding: 16px 20px;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .chat-header .avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: #7b2cbf;
        }

        .chat-header .info h3 {
            font-size: 1rem;
            font-weight: 600;
        }

        .chat-header .info span {
            font-size: 0.8rem;
            opacity: 0.9;
        }

        .chat-messages {
            padding: 20px;
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .message {
            max-width: 80%;
            animation: slideIn 0.3s ease;
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .message.incoming {
            align-self: flex-start;
        }

        .message.outgoing {
            align-self: flex-end;
        }

        .message .bubble {
            padding: 12px 16px;
            border-radius: 18px;
            font-size: 0.95rem;
            line-height: 1.5;
        }

        .message.incoming .bubble {
            background: #1e1e3f;
            color: #e6e6e6;
            border-bottom-left-radius: 4px;
        }

        .message.outgoing .bubble {
            background: linear-gradient(135deg, #7b2cbf, #5a1f9e);
            color: #fff;
            border-bottom-right-radius: 4px;
        }

        .message .timestamp {
            font-size: 0.7rem;
            color: #666;
            margin-top: 4px;
            padding: 0 8px;
        }

        .message.incoming .timestamp {
            text-align: left;
        }

        .message.outgoing .timestamp {
            text-align: right;
        }

        .typing-indicator {
            display: flex;
            gap: 4px;
            padding: 12px 16px;
            background: #1e1e3f;
            border-radius: 18px;
            width: fit-content;
        }

        .typing-indicator span {
            width: 8px;
            height: 8px;
            background: #666;
            border-radius: 50%;
            animation: bounce 1.4s infinite ease-in-out;
        }

        .typing-indicator span:nth-child(1) { animation-delay: 0s; }
        .typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
        .typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

        @keyframes bounce {
            0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
            40% { transform: scale(1); opacity: 1; }
        }

        .response-options {
            padding: 20px;
            background: #0f0f1a;
            border-radius: 16px;
            height: 100%;
        }

        .response-options h4 {
            font-size: 0.85rem;
            color: #8892b0;
            margin-bottom: 12px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .options-grid {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .option-btn {
            background: #1e1e3f;
            border: 2px solid transparent;
            border-radius: 12px;
            padding: 14px 18px;
            color: #ccd6f6;
            font-size: 0.9rem;
            text-align: left;
            cursor: pointer;
            transition: all 0.2s ease;
            line-height: 1.4;
        }

        .option-btn:hover {
            background: #2a2a5a;
            border-color: #7b2cbf;
            transform: translateX(4px);
        }

        .option-btn:focus {
            outline: none;
            background: #2a2a5a;
            border-color: #00d4ff;
            box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.3);
        }

        .option-btn:focus:not(:focus-visible) {
            box-shadow: none;
        }

        .option-btn:focus-visible {
            outline: none;
            background: #2a2a5a;
            border-color: #00d4ff;
            box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.3);
        }

        .option-btn.selected {
            border-color: #00d4ff;
            background: rgba(0, 212, 255, 0.1);
        }

        .option-btn.correct {
            border-color: #00ff88;
            background: rgba(0, 255, 136, 0.1);
        }

        .option-btn.incorrect {
            border-color: #ff4757;
            background: rgba(255, 71, 87, 0.1);
        }

        .feedback-panel {
            margin-top: 20px;
            padding: 16px;
            border-radius: 12px;
            display: none;
        }

        .feedback-panel.show {
            display: block;
            animation: slideIn 0.3s ease;
        }

        .feedback-panel.success {
            background: rgba(0, 255, 136, 0.1);
            border: 1px solid #00ff88;
        }

        .feedback-panel.error {
            background: rgba(255, 71, 87, 0.1);
            border: 1px solid #ff4757;
        }

        .feedback-panel h5 {
            font-size: 0.95rem;
            margin-bottom: 8px;
        }

        .feedback-panel.success h5 { color: #00ff88; }
        .feedback-panel.error h5 { color: #ff4757; }

        .feedback-panel p {
            color: #ccd6f6;
            font-size: 0.9rem;
            line-height: 1.5;
        }

        .controls {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 20px;
        }

        .progress {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .progress-bar {
            width: 200px;
            height: 6px;
            background: #1e1e3f;
            border-radius: 3px;
            overflow: hidden;
        }

        .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #7b2cbf, #00d4ff);
            transition: width 0.3s ease;
        }

        .progress-text {
            font-size: 0.85rem;
            color: #8892b0;
        }

        .btn {
            padding: 12px 24px;
            border: none;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-primary {
            background: linear-gradient(90deg, #7b2cbf, #5a1f9e);
            color: #fff;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 20px rgba(123, 44, 191, 0.4);
        }

        .btn-primary:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        .btn-primary:focus {
            outline: none;
            box-shadow: 0 0 0 3px rgba(123, 44, 191, 0.4);
        }

        .btn-secondary {
            background: transparent;
            border: 2px solid #7b2cbf;
            color: #7b2cbf;
        }

        .btn-secondary:hover {
            background: rgba(123, 44, 191, 0.1);
        }

        .btn-secondary:focus {
            outline: none;
            box-shadow: 0 0 0 3px rgba(123, 44, 191, 0.3);
        }

        .score-display {
            text-align: center;
            padding: 40px 20px;
            display: none;
            height: 500px;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: #0f0f1a;
            border-radius: 16px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.4);
        }

        .score-display.show {
            display: flex;
        }

        .score-display h2 {
            font-size: 2rem;
            margin-bottom: 10px;
            background: linear-gradient(90deg, #00d4ff, #7b2cbf);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .score-display .big-score {
            font-size: 4rem;
            font-weight: bold;
            color: #00ff88;
            margin: 20px 0;
        }

        .score-display p {
            color: #8892b0;
            margin-bottom: 30px;
        }

        .hidden {
            display: none !important;
        }
    </style>
</head>
<body>
    <div class="container">
        <div id="game-area">
            <div class="scenario-info">
                <h2>Scenario</h2>
                <p id="scenario-description">Loading scenario...</p>
            </div>

            <div class="main-layout">
                <div class="chat-window">
                    <div class="chat-header">
                        <div class="avatar" id="avatar">?</div>
                        <div class="info">
                            <h3 id="contact-name">Contact</h3>
                            <span id="contact-status">Online</span>
                        </div>
                    </div>

                    <div class="chat-messages" id="chat-messages">
                        <!-- Messages will be inserted here -->
                    </div>
                </div>

                <div class="response-panel">
                    <div class="response-options" id="response-options">
                        <h4>Choose your response:</h4>
                        <div class="options-grid" id="options-grid">
                            <!-- Options will be inserted here -->
                        </div>

                        <div class="feedback-panel" id="feedback-panel">
                            <h5 id="feedback-title">Feedback</h5>
                            <p id="feedback-text"></p>
                        </div>
                    </div>
                </div>
            </div>

            <div class="controls">
                <div class="progress">
                    <div class="progress-bar">
                        <div class="progress-fill" id="progress-fill" style="width: 0%"></div>
                    </div>
                    <span class="progress-text" id="progress-text">1 / 5</span>
                </div>
                <button class="btn btn-primary" id="next-btn" disabled>Next Scenario</button>
            </div>
        </div>

        <div class="score-display" id="score-display">
            <h2>Simulation Complete!</h2>
            <div class="big-score" id="final-score">0%</div>
            <p id="score-message">Great job practicing your communication skills!</p>
            <button class="btn btn-primary" id="restart-btn">Try Again</button>
        </div>
    </div>

    <script>
        // ============================================
        // PLATFORM CONFIGURATION
        // ============================================
        // Set 'platform' to either 'storyline' or 'rise'
        // For Storyline: Also set your variable name below
        // For Rise: No additional configuration needed
        // ============================================
        const CONFIG = {
            platform: 'storyline',              // 'storyline' or 'rise'
            storylineVariableName: 'simulationComplete'  // Only used when platform is 'storyline'
        };

        // Scenario data - customize these for your training needs
        const scenarios = [
            {
                context: "Customer Support",
                description: "A frustrated customer is complaining about a delayed shipment for the third time.",
                contact: { name: "Alex Rivera", status: "Frustrated customer", avatar: "AR" },
                messages: [
                    { type: "incoming", text: "This is absolutely ridiculous! My package was supposed to arrive THREE days ago and no one can tell me where it is!", time: "2:34 PM" },
                    { type: "incoming", text: "I've called twice already and gotten nowhere. Do you people even know what you're doing?", time: "2:35 PM" }
                ],
                options: [
                    { 
                        text: "I completely understand your frustration. Let me track down your package right now - can you give me your order number?",
                        correct: true,
                        feedback: "Excellent! You acknowledged their emotions, took ownership, and moved toward a solution while asking for specific information."
                    },
                    { 
                        text: "I'm really sorry to hear about this ongoing issue with your shipment. Unfortunately, our shipping delays are due to extremely high volume across all carriers right now, and we're experiencing longer wait times than usual. You'll need to wait like everyone else, but I can assure you it will arrive eventually.",
                        correct: false,
                        feedback: "This dismisses the customer's valid frustration and doesn't offer any help or empathy, despite the apologetic tone."
                    },
                    { 
                        text: "I apologize for the inconvenience. Have you tried checking the tracking number on our website? The system updates every few hours.",
                        correct: false,
                        feedback: "While polite, this deflects responsibility and suggests they should solve it themselves after they've already tried."
                    }
                ]
            },
            {
                context: "Workplace Communication",
                description: "A colleague just sent you work that has several errors, but they're sensitive to criticism.",
                contact: { name: "Jordan Chen", status: "Coworker • Design Team", avatar: "JC" },
                messages: [
                    { type: "incoming", text: "Hey! I finished the presentation slides you asked for. Took me all morning but I think they turned out great! 🎨", time: "11:42 AM" },
                    { type: "incoming", text: "Let me know what you think!", time: "11:42 AM" }
                ],
                options: [
                    { 
                        text: "There are quite a few errors here that we need to address before this can go out. The font is wrong on slides 2 and 5, the colors don't match our brand guidelines, slide 4 has a typo in the header, and the charts on slide 7 are using last quarter's data. Can you fix these?",
                        correct: false,
                        feedback: "This is too direct and critical without acknowledging their effort, which could damage the working relationship."
                    },
                    { 
                        text: "Thanks Jordan! I have a few thoughts that might strengthen the impact - mind if we review together?",
                        correct: true,
                        feedback: "Perfect approach! You acknowledged their effort, stayed positive, and framed feedback as collaboration rather than criticism."
                    },
                    { 
                        text: "Looks good! 👍",
                        correct: false,
                        feedback: "Avoiding necessary feedback doesn't help Jordan improve and could cause problems later when the errors are discovered."
                    }
                ]
            },
            {
                context: "Difficult Personal Conversation",
                description: "A friend is venting about their job but you've heard this same complaint many times without them taking action.",
                contact: { name: "Sam Martinez", status: "Close friend", avatar: "SM" },
                messages: [
                    { type: "incoming", text: "Ugh my boss did it AGAIN. Took credit for my entire project in front of the executives.", time: "7:15 PM" },
                    { type: "incoming", text: "I swear I'm going to quit one of these days. This place is toxic.", time: "7:16 PM" }
                ],
                options: [
                    { 
                        text: "You always say you're going to quit but you never actually do anything about it. I've heard this same story at least ten times now. At some point you have to stop complaining and actually make a change, or just accept that this is how things are.",
                        correct: false,
                        feedback: "While honest, this comes across as dismissive and could make your friend feel judged rather than supported."
                    },
                    { 
                        text: "That's unfair, and I can tell it's wearing you down. What would need to happen for you to feel ready to make a change?",
                        correct: true,
                        feedback: "Great balance! You validated their feelings while gently encouraging them to think about concrete next steps."
                    },
                    { 
                        text: "That's terrible! Your boss sounds absolutely awful and that workplace is clearly toxic. You should definitely quit - you deserve so much better than this!",
                        correct: false,
                        feedback: "Just agreeing without helping them process might feel supportive but doesn't help them move forward."
                    }
                ]
            },
            {
                context: "Handling Conflict",
                description: "Someone in a group chat is spreading misinformation about a topic you know well.",
                contact: { name: "Community Chat", status: "12 members online", avatar: "CC" },
                messages: [
                    { type: "incoming", text: "[Mike]: I read that the new city ordinance means we can't have backyard fires anymore at ALL. They're basically criminalizing outdoor living!", time: "6:22 PM" },
                    { type: "incoming", text: "[Lisa]: Wow that's crazy! When does this start??", time: "6:23 PM" }
                ],
                options: [
                    { 
                        text: "That's completely wrong Mike. Maybe try actually reading the ordinance before spreading panic and misinformation to everyone. It takes two minutes to look this stuff up.",
                        correct: false,
                        feedback: "While factually correct, this approach is aggressive and likely to make Mike defensive rather than receptive."
                    },
                    { 
                        text: "I'm not sure that's accurate but I could be wrong. Does anyone else know more about this?",
                        correct: false,
                        feedback: "Being too timid about correcting misinformation allows it to spread. You can be kind AND confident."
                    },
                    { 
                        text: "Hey Mike, I looked into this! It's only about fire pits within 15 feet of structures. Regular backyard fires are still fine. Here's the city link: [link]",
                        correct: true,
                        feedback: "Excellent! You corrected the misinformation without being confrontational, provided the accurate information, and offered a source."
                    }
                ]
            },
            {
                context: "Setting Boundaries",
                description: "A client is asking you to do work outside your agreed scope, for the third time this month.",
                contact: { name: "Taylor Brooks", status: "Client • Acme Corp", avatar: "TB" },
                messages: [
                    { type: "incoming", text: "Quick favor - can you also update the logo on our other 5 websites while you're at it? Should only take a few minutes!", time: "3:45 PM" },
                    { type: "incoming", text: "We're in a rush so I'd need it by EOD", time: "3:45 PM" }
                ],
                options: [
                    { 
                        text: "Sure, I can squeeze it in! I know you're in a rush and it shouldn't take too long. I'll get it done by end of day for you, no problem at all.",
                        correct: false,
                        feedback: "Saying yes to scope creep without addressing it trains clients to keep asking and undervalues your work."
                    },
                    { 
                        text: "That's not in scope. You'll need to submit a new request through proper channels.",
                        correct: false,
                        feedback: "While technically correct, this is too cold and bureaucratic for maintaining a good client relationship."
                    },
                    { 
                        text: "Happy to help! That falls outside our current agreement, so I'll send a quick quote. I could have it done by tomorrow noon - work for you?",
                        correct: true,
                        feedback: "Perfect! You stayed friendly, clearly established it's additional work, offered a realistic timeline, and kept the door open."
                    }
                ]
            }
        ];

        // Shuffle array helper function
        function shuffleArray(array) {
            const shuffled = [...array];
            for (let i = shuffled.length - 1; i > 0; i--) {
                const j = Math.floor(Math.random() * (i + 1));
                [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
            }
            return shuffled;
        }

        // Game state
        let currentScenario = 0;
        let score = 0;
        let answered = false;
        let currentShuffledOptions = [];

        // DOM elements
        const scenarioDescription = document.getElementById('scenario-description');
        const contactName = document.getElementById('contact-name');
        const contactStatus = document.getElementById('contact-status');
        const avatar = document.getElementById('avatar');
        const chatMessages = document.getElementById('chat-messages');
        const optionsGrid = document.getElementById('options-grid');
        const feedbackPanel = document.getElementById('feedback-panel');
        const feedbackTitle = document.getElementById('feedback-title');
        const feedbackText = document.getElementById('feedback-text');
        const progressFill = document.getElementById('progress-fill');
        const progressText = document.getElementById('progress-text');
        const nextBtn = document.getElementById('next-btn');
        const gameArea = document.getElementById('game-area');
        const scoreDisplay = document.getElementById('score-display');
        const finalScore = document.getElementById('final-score');
        const scoreMessage = document.getElementById('score-message');
        const restartBtn = document.getElementById('restart-btn');

        // Handle option selection
        function selectOption(index, shuffledOptions = currentShuffledOptions) {
            if (answered) return;
            answered = true;

            const option = shuffledOptions[index];
            const buttons = optionsGrid.querySelectorAll('.option-btn');

            // Show selected response in chat
            addMessage('outgoing', option.text, 'Just now');

            // Highlight correct/incorrect
            buttons.forEach((btn, i) => {
                btn.style.pointerEvents = 'none';
                btn.setAttribute('tabindex', '-1');
                if (i === index) {
                    btn.classList.add(option.correct ? 'correct' : 'incorrect');
                }
                if (shuffledOptions[i].correct && i !== index) {
                    btn.classList.add('correct');
                }
            });

            // Show feedback
            feedbackPanel.classList.add('show', option.correct ? 'success' : 'error');
            feedbackTitle.textContent = option.correct ? '✓ Great choice!' : '✗ Not quite';
            feedbackText.textContent = option.feedback;

            if (option.correct) {
                score++;
            }

            nextBtn.disabled = false;
        }

        // Load a scenario
        function loadScenario(index) {
            const scenario = scenarios[index];
            answered = false;
            
            // Update scenario info
            scenarioDescription.textContent = `${scenario.context}: ${scenario.description}`;
            contactName.textContent = scenario.contact.name;
            contactStatus.textContent = scenario.contact.status;
            avatar.textContent = scenario.contact.avatar;

            // Clear and load messages
            chatMessages.innerHTML = '';
            scenario.messages.forEach((msg, i) => {
                setTimeout(() => {
                    addMessage(msg.type, msg.text, msg.time);
                }, i * 300);
            });

            // Load options (shuffled)
            optionsGrid.innerHTML = '';
            const shuffledOptions = shuffleArray(scenario.options);
            shuffledOptions.forEach((option, i) => {
                const btn = document.createElement('button');
                btn.className = 'option-btn';
                btn.textContent = option.text;
                btn.setAttribute('tabindex', '0');
                btn.setAttribute('data-index', i);
                btn.addEventListener('click', () => selectOption(i, shuffledOptions));
                optionsGrid.appendChild(btn);
            });

            // Store shuffled options for reference
            currentShuffledOptions = shuffledOptions;

            // Reset UI
            feedbackPanel.classList.remove('show', 'success', 'error');
            nextBtn.disabled = true;
            updateProgress();
        }

        // Add a message to the chat
        function addMessage(type, text, time) {
            const messageDiv = document.createElement('div');
            messageDiv.className = `message ${type}`;
            messageDiv.innerHTML = `
                <div class="bubble">${text}</div>
                <div class="timestamp">${time}</div>
            `;
            chatMessages.appendChild(messageDiv);
        }

        // Update progress indicator
        function updateProgress() {
            const progress = ((currentScenario + 1) / scenarios.length) * 100;
            progressFill.style.width = `${progress}%`;
            progressText.textContent = `${currentScenario + 1} / ${scenarios.length}`;
        }

        // Show final score
        function showFinalScore() {
            gameArea.classList.add('hidden');
            scoreDisplay.classList.add('show');
            
            const percentage = Math.round((score / scenarios.length) * 100);
            finalScore.textContent = `${percentage}%`;
            
            if (percentage === 100) {
                scoreMessage.textContent = "Perfect! You're a communication master! 🎯";
                finalScore.style.color = '#00ff88';
            } else if (percentage >= 60) {
                scoreMessage.textContent = "Good job! You handled most situations well. 👍";
                finalScore.style.color = '#00d4ff';
            } else {
                scoreMessage.textContent = "Keep practicing! Communication is a skill that improves with time. 💪";
                finalScore.style.color = '#ffaa00';
            }

            // Send completion to parent application
            sendCompletion();
        }

        // Platform-specific completion handler
        function sendCompletion() {
            if (CONFIG.platform === 'rise') {
                // Rise 360: Use postMessage to communicate completion
                window.parent.postMessage({ type: 'complete' }, '*');
            } else if (CONFIG.platform === 'storyline') {
                // Storyline: Set the variable directly via GetPlayer()
                try {
                    const player = parent.GetPlayer();
                    player.SetVar(CONFIG.storylineVariableName, true);
                } catch (e) {
                    console.warn('Could not communicate with Storyline:', e);
                }
            }
        }

        // Restart the simulation
        function restartGame() {
            currentScenario = 0;
            score = 0;
            scoreDisplay.classList.remove('show');
            gameArea.classList.remove('hidden');
            loadScenario(0);
        }

        // Event listeners
        nextBtn.addEventListener('click', () => {
            currentScenario++;
            if (currentScenario < scenarios.length) {
                loadScenario(currentScenario);
            } else {
                showFinalScore();
            }
        });

        restartBtn.addEventListener('click', restartGame);

        // Keyboard navigation
        document.addEventListener('keydown', (e) => {
            const options = Array.from(optionsGrid.querySelectorAll('.option-btn'));
            const focusedElement = document.activeElement;
            const currentIndex = options.indexOf(focusedElement);

            // Arrow key navigation within options
            if (options.length > 0 && !answered) {
                if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
                    e.preventDefault();
                    const nextIndex = currentIndex < options.length - 1 ? currentIndex + 1 : 0;
                    options[nextIndex].focus();
                } else if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
                    e.preventDefault();
                    const prevIndex = currentIndex > 0 ? currentIndex - 1 : options.length - 1;
                    options[prevIndex].focus();
                } else if ((e.key === 'Enter' || e.key === ' ') && currentIndex !== -1) {
                    e.preventDefault();
                    selectOption(currentIndex);
                }
            }

            // Enter/Space to advance to next scenario or restart
            if (e.key === 'Enter' || e.key === ' ') {
                if (answered && !nextBtn.disabled && focusedElement !== restartBtn) {
                    if (currentScenario < scenarios.length - 1 || !scoreDisplay.classList.contains('show')) {
                        e.preventDefault();
                        nextBtn.click();
                    }
                }
                if (scoreDisplay.classList.contains('show') && focusedElement === restartBtn) {
                    e.preventDefault();
                    restartGame();
                }
            }
        });

        // Initialize
        loadScenario(0);
    </script>
</body>
</html>

How the JavaScript Works

Let's break down the key parts of the code so you understand what's happening under the hood. This knowledge will help you customize the simulator for your specific training needs.

Managing Game State

The simulator tracks several pieces of information throughout the experience. The currentScenario variable keeps track of which scenario the learner is viewing. The score variable counts how many correct responses the learner has selected. The answered flag prevents learners from clicking multiple options for the same scenario.

let currentScenario = 0;
let score = 0;
let answered = false;
let currentShuffledOptions = [];

Loading Scenarios

The loadScenario function handles displaying each new scenario. It updates the contact information in the chat header, clears any previous messages, and adds the new messages with a slight delay between each one to create a realistic feel.

The function also shuffles the response options using the Fisher-Yates algorithm. This randomization prevents learners from memorizing answer positions when retaking the simulation.

Processing Responses

When a learner clicks a response option, the selectOption function takes over. It adds their chosen response to the chat as an outgoing message, highlights whether they chose correctly or incorrectly, reveals the correct answer if they chose wrong, and displays contextual feedback explaining the outcome.

Communicating with Storyline or Rise

The simulator uses different methods to signal completion depending on which platform you're using. The sendCompletion function handles this automatically based on your CONFIG setting:

function sendCompletion() {
    if (CONFIG.platform === 'rise') {
        window.parent.postMessage({ type: 'complete' }, '*');
    } else if (CONFIG.platform === 'storyline') {
        try {
            const player = parent.GetPlayer();
            player.SetVar(CONFIG.storylineVariableName, true);
        } catch (e) {
            console.warn('Could not communicate with Storyline:', e);
        }
    }
}

For Storyline, the code uses parent.GetPlayer() to access the Storyline player API and set a variable directly. This is more reliable than postMessage because it doesn't require an additional trigger on the Storyline slide.

For Rise 360, the code sends a postMessage to the parent window. Rise listens for these messages and can use them to track block completion.

Connecting the Simulator to Storyline or Rise 360

The simulator works in both Articulate Storyline and Rise 360, but each platform handles completion differently. Before using the code, set the platform value in the CONFIG section at the top of the HTML file.

Configuration Options

At the top of the HTML file, you'll find a CONFIG object:

const CONFIG = {
    platform: 'storyline',              // 'storyline' or 'rise'
    storylineVariableName: 'simulationComplete'  // Only used when platform is 'storyline'
};

Change platform to 'rise' if you're embedding this in a Rise 360 course. For Storyline, keep it as 'storyline' and adjust the variable name if needed.

How Completion Works in Each Platform

The sendCompletion function handles the platform differences:

function sendCompletion() {
    if (CONFIG.platform === 'rise') {
        // Rise 360: Use postMessage to communicate completion
        window.parent.postMessage({ type: 'complete' }, '*');
    } else if (CONFIG.platform === 'storyline') {
        // Storyline: Set the variable directly via GetPlayer()
        try {
            const player = parent.GetPlayer();
            player.SetVar(CONFIG.storylineVariableName, true);
        } catch (e) {
            console.warn('Could not communicate with Storyline:', e);
        }
    }
}

For Rise 360, the simulator sends a postMessage that Rise can listen for. For Storyline, it directly sets a variable using the GetPlayer() API.

Storyline Setup

If you're using Storyline, create a trigger that responds to the variable change:

  1. Click Create a new trigger

  2. Set Action to Change state of (for a button) or Show layer (for feedback)

  3. Set When to Variable changes

  4. Select your simulationComplete variable

  5. Add a condition: simulationComplete is equal to True

This approach is simpler than listening for postMessage because the simulator sets the variable directly.

Rise 360 Setup

In Rise 360, add the HTML file as a Multimedia block:

  1. Add a Code block to your lesson

  2. Select Code, and Select code

  3. Copy and paste your code into the code block

  4. In the block settings, enable Set completion requirements

Rise 360 will receive the postMessage when learners complete the simulation. Depending on your Rise settings, this can mark the block as complete.

Customizing Your Scenarios

The sample code includes five diverse scenarios covering customer support, workplace communication, personal conversations, conflict handling, and boundary setting. You'll want to replace these with scenarios relevant to your training content.

Adding New Scenarios

To add a scenario, copy the structure of an existing one in the scenarios array and modify the values. Each scenario needs a context that appears as a label, a description explaining the situation, contact details with a name, status, and avatar initials, one or more incoming messages with timestamps, and three response options with one marked as correct.

Writing Effective Response Options

The power of this simulator comes from well-crafted response options. Each option should be plausible—learners should have to think about which response is best. The incorrect options should represent common mistakes people actually make, not obviously wrong choices.

Write feedback that explains the reasoning behind why an option works or doesn't work. This transforms a simple right-or-wrong activity into a genuine learning experience.

Accessibility Considerations

The simulator includes several accessibility features built in. All interactive elements are keyboard accessible, allowing learners to navigate using Tab, Arrow keys, Enter, and Space. Focus states are clearly visible with a cyan border and glow effect. The color contrast meets WCAG AA standards for readability.

If you need to enhance accessibility further, consider adding ARIA labels to the response buttons, providing a text alternative summary of each scenario, and ensuring your Storyline project's accessibility settings are properly configured.

Troubleshooting Common Issues

If your simulator isn't working as expected, check these common issues.

Web Object Not Loading

Make sure your HTML file is saved in the same folder as your Storyline project or in a subfolder. Verify the file path is correct in the web object settings. Try opening the HTML file directly in a browser to confirm it works independently.

Completion Variable Not Updating

Confirm your JavaScript trigger is on the same slide as the web object. Check that the variable name in your trigger exactly matches the variable you created. Test by publishing your project—preview mode sometimes handles web objects differently.

Styling Looks Different in Storyline

Storyline's web object uses an embedded browser that may render CSS slightly differently. Test your published output in multiple browsers. Consider adding fallback fonts and avoiding cutting-edge CSS features.

Taking It Further

Once you have the basic simulator working, consider these enhancements for future iterations. You could add branching paths where the conversation continues differently based on responses. A timer element could add pressure to scenarios where quick responses matter. Score tracking across multiple attempts could motivate improvement.

The modular structure of the code makes these additions straightforward. The scenario data is separate from the display logic, so you can add new scenarios without modifying the core functionality.

Wrapping Up

You now have a fully functional chat response simulator that runs inside Articulate Storyline. This interaction type offers learners a safe space to practice difficult conversations, receive immediate feedback, and build communication skills that transfer to real-world situations.

The complete code is ready to use—just customize the scenarios for your training content and drop it into your Storyline project. Your learners will appreciate the engaging, realistic practice this format provides.

Download the code and start building your own chat simulations today.

Nathan Stoker

I build custom eLearning in Storyline, Rise and JavaScript, and I make the free tools and templates on this site. Need an interaction like this in your course? Let's talk.

Work with me · Browse templates

Related posts