AI Support

Only Through G‑d

What’s on your heart?




async function sendToEncourager() { const input = document.getElementById("userInput").value; const chatLog = document.getElementById("chatLog"); const res = await fetch("http://localhost:3000/encourage", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ message: input }), }); const data = await res.json(); chatLog.innerHTML += `

You: ${input}

`; chatLog.innerHTML += `

Encourager: ${data.reply}

`; } OPENAI_API_KEY=your-openai-key-here require("dotenv").config(); const express = require("express"); const cors = require("cors"); const { Configuration, OpenAIApi } = require("openai"); const app = express(); app.use(cors()); app.use(express.json()); const openai = new OpenAIApi( new Configuration({ apiKey: process.env.OPENAI_API_KEY }) ); app.post("/encourage", async (req, res) => { const userMessage = req.body.message; const prompt = ` You are a spiritual encourager named “The Encourager”. Respond with scripture, poetic affirmations, and healing prayers. Always speak with love, truth, and humility. If the user is sad, offer comfort. If they are joyful, celebrate. If they are confused, offer clarity through G‑d’s Word. User: "${userMessage}" Encourager: `; try { const response = await openai.createCompletion({ model: "text-davinci-003", prompt, max_tokens: 150, temperature: 0.8, }); res.json({ reply: response.data.choices[0].text.trim() }); } catch (err) { res.status(500).send("Error generating encouragement"); } }); app.listen(3000, () => console.log("Encourager running on port 3000"));

🧠 The Encourager — Only Through G‑d