Millions of displaced children grow up without a single storybook. StoryAI changes that by generating age‑appropriate, culturally‑sensitive tales on‑demand and delivering them over the low‑bandwidth channels that dominate refugee camps—WhatsApp, SMS, or even offline‑first devices.
Since the product’s debut on Product Hunt and the sharp rise in Google Trends for “children’s stories + refugees,” NGOs are asking: How do we turn a prototype into a privacy‑first, sustainable service? This guide gives you the practical steps, code snippets, and deployment tips you need to start today.
| Component | What It Does | Quick‑Start Command |
|---|---|---|
| Prompt Builder | Adds age, language, and cultural tags to steer the LLM. | python build_prompt.py --age 5-7 --culture Ukrainian --lang es |
| LLM Backend | Calls GPT‑4, Claude, or LLaMA via OpenAI/Anthropic/Meta APIs. | curl -X POST https://api.openai.com/v1/chat/completions \ <br> -H "Authorization: Bearer $OPENAI_KEY" \ <br> -H "Content-Type: application/json" \ <br> -d '{"model":"gpt-4","messages":[{"role":"system","content":"You are a children’s author..."}]}' |
| Safety Filter | Rejects any output containing violence, hate, or adult content. | python filter.py --input story.txt --policy ./policies/child_safe.yaml |
| Human Review Queue (optional) | Sends flagged stories to a reviewer Slack channel. | slack webhook https://hooks.slack.com/services/... --payload @story.txt |
| Delivery Engine | Sends text via Twilio SMS, WhatsApp Business API, or serves locally from an edge node. | twilio sms:create --to +1234567890 --from +1987654321 --body "$(cat story.txt)" |
| Edge Cache | Raspberry Pi Docker container that pre‑downloads a daily batch for offline use. | docker run -d --restart unless‑stopped \ <br> -v $(pwd)/cache:/app/cache \ <br> storyai/edge:latest sync |
git clone https://github.com/storyai/core.git
cd storyai
pip install -r requirements.txt
python build_prompt.py --age 5-7 --culture Ukrainian --lang es > prompt.txt
The resulting prompt.txt looks like:
You are a children’s author. Write a short story for a 6‑year‑old (age:5-7) in Spanish. The story must reflect Ukrainian cultural elements (e.g., sunflower fields, traditional lullabies) and contain no violence or adult themes.
curl -s -X POST https://api.anthropic.com/v1/complete \
-H "x-api-key: $ANTHROPIC_KEY" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"model": "claude-2.1",
"prompt": "$(cat prompt.txt)",
"max_tokens_to_sample": 500,
"temperature": 0.7
}
EOF > story_raw.txt
python filter.py --input story_raw.txt --policy policies/child_safe.yaml --output story.txt
if [ $? -ne 0 ]; then
echo "Content rejected – send to human reviewer"
slack webhook https://hooks.slack.com/services/... --payload @story_raw.txt
exit 1
fi
SMS (Twilio)
twilio sms:create \
--to +1234567890 \
--from +1987654321 \
--body "$(cat story.txt)"
WhatsApp (Business API)
curl -X POST https://graph.facebook.com/v17.0/<PHONE_NUMBER_ID>/messages \
-H "Authorization: Bearer $WHATSAPP_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product":"whatsapp",
"to":"1234567890",
"type":"text",
"text":{"body":"'"$(cat story.txt)"'"}
}'
Offline Edge Node
docker exec -it storyai_edge sync # pulls the daily batch
docker exec -it storyai_edge serve # opens a local Wi‑Fi hotspot at http://10.0.0.1
Camp volunteers can now hand out a simple QR code that points to the hotspot; families download stories directly to a cheap Android tablet.
from uuid import uuid5, NAMESPACE_DNS
def tokenise(phone):
return uuid5(NAMESPACE_DNS, phone)
log = {
"user_id": tokenise("+1234567890"),
"story_id": "ukr_es_2024_04_12",
"timestamp": datetime.utcnow().isoformat()
}
requests.post("https://analytics.storyai.org/collect", json=log, verify=True)
All data is encrypted at rest (AES‑256) and complies with GDPR and the UN Convention on the Rights of the Child.
| Question | Practical Answer |
|---|---|
| How do I guarantee age‑appropriate content across cultures? | Use the prompt tags ( age ,culture ,language )and the built‑in safety filter. Fine‑tune the model on a curated UNESCO‑approved corpus; the filter will automatically reject any story that contains disallowed tokens. |
| What are the privacy requirements for phone numbers? | Store only a deterministic hash (as shown above) for analytics. Keep raw numbers in a separate, encrypted table that is never queried for reporting. Record consent with a timestamped “YES” SMS reply; this single line satisfies GDPR’s consent‑record requirement. |
| Can the system run without internet? | Yes. Deploy the Dockerized edge container on a Raspberry Pi or similar SBC. It syncs once per day when a mobile hotspot is available, then serves stories locally via Wi‑Fi or Bluetooth. |
| Which LLM should I start with? | GPT‑4 offers the most robust safety controls out of the box, but Claude‑2.1 and LLaMA‑2‑13B are cheaper for high‑volume deployments. Test all three on a small batch and compare cost per 1 000 characters. |
| How do I handle audio versions for low‑literacy users? | After the text is approved, pipe it through a TTS engine (e.g., Google Cloud Text‑to‑Speech) and store the MP3 alongside the text. The edge node can serve both files; the client app plays the audio automatically when the story is opened. |
0 2 * * * docker exec storyai_edge sync).
With these concrete steps, you can move from a proof‑of‑concept to a reliable, privacy‑first storytelling service that reaches the children who need it most—today.
Herramienta mencionada: Groq Cloud