# Building an AI Fairy Tale Generator with JavaScript, PowerShell, .NET, and Local Ollama (AdvantageBuilder Demo)

> Source: <https://dev.to/advantage_builder/building-an-ai-fairy-tale-generator-with-javascript-powershell-net-and-local-ollama-28aa>
> Published: 2026-08-28 04:04:53+00:00

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.

🎬 Watch the full demo:

[https://youtu.be/ah8jf_WwkLE](https://youtu.be/ah8jf_WwkLE)

This article breaks down how the workflow works and includes real code examples you can use inside AdvantageBuilder.

⭐ Why This Demo Is Interesting

Most AI demos rely on cloud APIs. This one runs entirely locally:

JavaScript V8 macro

PowerShell helper

Ollama model (llama3.1:8b-instruct-q4_K_M)

.NET System.Speech voice narration

All orchestrated inside AdvantageBuilder

It’s a clean example of multi‑runtime automation.

The main macro is written in JavaScript V8. It calls two helpers:

AI Ollama Helper → generates the fairy tale

InvokeSpeech → narrates the fairy tale aloud

Here’s a simplified version of the JS macro:

```
[!JAVASCRIPTV8]

// --- Step 1: Generate a fairy tale using the AI helper ---
let aiParams = {};
aiParams.Model = "llama3.1:8b-instruct-q4_K_M";
aiParams.Prompt = "Write a short fairy tale suitable for narration. Keep it under 200 words.";

let fairyTale = callMacro(false, 'AI Ollama Helper', 'Macro Main Helpers', aiParams);

// --- Step 2: Feed the fairy tale to the voice helper ---
let voiceParams = {};
voiceParams.Voice = "Microsoft Zira Desktop";   // or David
voiceParams.TextToSpeech = fairyTale;

callMacro(false, 'InvokeSpeech', 'Macro Main Helpers', voiceParams);

[!/JAVASCRIPTV8]
```

AdvantageBuilder automatically handles:

So JavaScript can call PowerShell seamlessly.

This helper sends a prompt to Ollama’s local REST API and returns the generated text.

``` php
[!POWERSHELLSCRIPT]

# $_args.Model
# $_args.Prompt

$model = "llama3.1:8b-instruct-q4_K_M"
$prompt = ""

if($_args -ne $null){

    $model = $_args.Model
    $prompt = $_args.Prompt
}

$body = @{
    model  = $model
    prompt = $prompt
    stream = $false
} | ConvertTo-Json -Depth 5

$response = Invoke-RestMethod -Uri "http://localhost:11434/api/generate" `
    -Method POST `
    -Body $body `
    -ContentType "application/json"

$response.response

[!/POWERSHELLSCRIPT]
```

This is all you need to integrate local AI into AdvantageBuilder.

This helper uses System.Speech to speak the generated fairy tale aloud.

```
[!POWERSHELLSCRIPT]

Add-Type -AssemblyName System.Speech

# Create synthesizer
$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer

$synth.SelectVoice($_args.Voice)
$synth.Speak($_args.TextToSpeech)

[!/POWERSHELLSCRIPT]
```

AdvantageBuilder’s WinFormsHelper can also build a UI for selecting voices.

AdvantageBuilder is designed for **multi‑runtime orchestration**:

In this workflow:

All inside one macro.

This is the kind of automation that normally requires multiple tools, but AdvantageBuilder handles it natively.

This architecture can power:

If you want to explore local AI without cloud dependencies, this setup is a great starting point.

See the entire workflow — including the helpers, narration, and macro execution — in the video:
