{"slug": "building-an-ai-fairy-tale-generator-with-javascript-powershell-net-and-local", "title": "Building an AI Fairy Tale Generator with JavaScript, PowerShell, .NET, and Local Ollama (AdvantageBuilder Demo)", "summary": "A developer demonstrated AdvantageBuilder's ability to orchestrate multiple runtimes—JavaScript V8, PowerShell, .NET, and local AI via Ollama—to generate and narrate fairy tales entirely offline. The workflow uses a JavaScript macro to call a PowerShell helper that queries Ollama's local REST API with the llama3.1 model, then feeds the generated text to a .NET System.Speech helper for voice narration.", "body_md": "Recently I published a demo showing how AdvantageBuilder can orchestrate multiple runtimes — JavaScript V8, PowerShell, .NET, and local AI (Ollama) — to generate and narrate fairy tales on demand.\n\n🎬 Watch the full demo:\n\n[https://youtu.be/ah8jf_WwkLE](https://youtu.be/ah8jf_WwkLE)\n\nThis article breaks down how the workflow works and includes real code examples you can use inside AdvantageBuilder.\n\n⭐ Why This Demo Is Interesting\n\nMost AI demos rely on cloud APIs. This one runs entirely locally:\n\nJavaScript V8 macro\n\nPowerShell helper\n\nOllama model (llama3.1:8b-instruct-q4_K_M)\n\n.NET System.Speech voice narration\n\nAll orchestrated inside AdvantageBuilder\n\nIt’s a clean example of multi‑runtime automation.\n\nThe main macro is written in JavaScript V8. It calls two helpers:\n\nAI Ollama Helper → generates the fairy tale\n\nInvokeSpeech → narrates the fairy tale aloud\n\nHere’s a simplified version of the JS macro:\n\n```\n[!JAVASCRIPTV8]\n\n// --- Step 1: Generate a fairy tale using the AI helper ---\nlet aiParams = {};\naiParams.Model = \"llama3.1:8b-instruct-q4_K_M\";\naiParams.Prompt = \"Write a short fairy tale suitable for narration. Keep it under 200 words.\";\n\nlet fairyTale = callMacro(false, 'AI Ollama Helper', 'Macro Main Helpers', aiParams);\n\n// --- Step 2: Feed the fairy tale to the voice helper ---\nlet voiceParams = {};\nvoiceParams.Voice = \"Microsoft Zira Desktop\";   // or David\nvoiceParams.TextToSpeech = fairyTale;\n\ncallMacro(false, 'InvokeSpeech', 'Macro Main Helpers', voiceParams);\n\n[!/JAVASCRIPTV8]\n```\n\nAdvantageBuilder automatically handles:\n\nSo JavaScript can call PowerShell seamlessly.\n\nThis helper sends a prompt to Ollama’s local REST API and returns the generated text.\n\n``` php\n[!POWERSHELLSCRIPT]\n\n# $_args.Model\n# $_args.Prompt\n\n$model = \"llama3.1:8b-instruct-q4_K_M\"\n$prompt = \"\"\n\nif($_args -ne $null){\n\n    $model = $_args.Model\n    $prompt = $_args.Prompt\n}\n\n$body = @{\n    model  = $model\n    prompt = $prompt\n    stream = $false\n} | ConvertTo-Json -Depth 5\n\n$response = Invoke-RestMethod -Uri \"http://localhost:11434/api/generate\" `\n    -Method POST `\n    -Body $body `\n    -ContentType \"application/json\"\n\n$response.response\n\n[!/POWERSHELLSCRIPT]\n```\n\nThis is all you need to integrate local AI into AdvantageBuilder.\n\nThis helper uses System.Speech to speak the generated fairy tale aloud.\n\n```\n[!POWERSHELLSCRIPT]\n\nAdd-Type -AssemblyName System.Speech\n\n# Create synthesizer\n$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer\n\n$synth.SelectVoice($_args.Voice)\n$synth.Speak($_args.TextToSpeech)\n\n[!/POWERSHELLSCRIPT]\n```\n\nAdvantageBuilder’s WinFormsHelper can also build a UI for selecting voices.\n\nAdvantageBuilder is designed for **multi‑runtime orchestration**:\n\nIn this workflow:\n\nAll inside one macro.\n\nThis is the kind of automation that normally requires multiple tools, but AdvantageBuilder handles it natively.\n\nThis architecture can power:\n\nIf you want to explore local AI without cloud dependencies, this setup is a great starting point.\n\nSee the entire workflow — including the helpers, narration, and macro execution — in the video:", "url": "https://wpnews.pro/news/building-an-ai-fairy-tale-generator-with-javascript-powershell-net-and-local", "canonical_source": "https://dev.to/advantage_builder/building-an-ai-fairy-tale-generator-with-javascript-powershell-net-and-local-ollama-28aa", "published_at": "2026-08-28 04:04:53+00:00", "updated_at": "2026-08-28 04:19:28.947037+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "large-language-models"], "entities": ["AdvantageBuilder", "Ollama", "JavaScript V8", "PowerShell", ".NET", "System.Speech", "llama3.1"], "alternates": {"html": "https://wpnews.pro/news/building-an-ai-fairy-tale-generator-with-javascript-powershell-net-and-local", "markdown": "https://wpnews.pro/news/building-an-ai-fairy-tale-generator-with-javascript-powershell-net-and-local.md", "text": "https://wpnews.pro/news/building-an-ai-fairy-tale-generator-with-javascript-powershell-net-and-local.txt", "jsonld": "https://wpnews.pro/news/building-an-ai-fairy-tale-generator-with-javascript-powershell-net-and-local.jsonld"}}