CognxSafeTrack commited on
Commit ·
fc3b1c4
1
Parent(s): f32bf87
fix(prod): in-process seed + DNS fix for worker ENOTFOUND
Browse files
apps/api/src/services/whatsapp.ts
CHANGED
|
@@ -38,9 +38,66 @@ export class WhatsAppService {
|
|
| 38 |
if (normalizedText === 'SEED') {
|
| 39 |
await scheduleMessage(user.id, "🔄 Lancement du seeding en cours...");
|
| 40 |
try {
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
} catch (err: any) {
|
| 45 |
console.error('Seed Error:', err);
|
| 46 |
await scheduleMessage(user.id, `❌ Erreur de seed : ${err.message}`);
|
|
|
|
| 38 |
if (normalizedText === 'SEED') {
|
| 39 |
await scheduleMessage(user.id, "🔄 Lancement du seeding en cours...");
|
| 40 |
try {
|
| 41 |
+
// Run seed logic directly in-process (no child_process, no path issues)
|
| 42 |
+
const existingFR = await prisma.track.findFirst({ where: { title: "Comprendre Son Business (FR)" } });
|
| 43 |
+
if (existingFR) {
|
| 44 |
+
await scheduleMessage(user.id, "ℹ️ Les données existent déjà en base. Aucun seeding nécessaire !");
|
| 45 |
+
return;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// Seed FR track
|
| 49 |
+
await prisma.track.create({
|
| 50 |
+
data: {
|
| 51 |
+
title: "Comprendre Son Business (FR)",
|
| 52 |
+
description: "Apprenez à définir, tester et vendre votre projet en 12 leçons.",
|
| 53 |
+
duration: 12,
|
| 54 |
+
language: "FR",
|
| 55 |
+
days: {
|
| 56 |
+
create: [
|
| 57 |
+
{ dayNumber: 1, exerciseType: "AUDIO", lessonText: "Aujourd'hui, on commence simple. Beaucoup de personnes disent : je fais le commerce. Mais ça ne veut rien dire. Dis-moi clairement : Tu aides QUI, à faire QUOI, et comment tu gagnes de l'argent. Exemple : Je vends du jus bissap aux étudiants devant l'université. Maintenant, c'est à toi. Dis ta phrase en 15 secondes.", exercisePrompt: "Envoie-moi un court message vocal (ou texte) avec ta phrase d'activité :" },
|
| 58 |
+
{ dayNumber: 2, exerciseType: "AUDIO", lessonText: "Le client n'achète pas ton produit. Il achète un résultat. Il n'achète pas du savon. Il achète la propreté. Va demander à 2 clients : Pourquoi tu achètes ça ? Écoute bien leurs mots.", exercisePrompt: "Envoie un audio résumant les 2 réponses de tes clients." },
|
| 59 |
+
{ dayNumber: 3, exerciseType: "BUTTON", lessonText: "Si tu vends à tout le monde, tu ne vends à personne. Choisis un seul client principal. Qui est le plus intéressé par ton produit ?", exercisePrompt: "Sélectionne ton client principal ci-dessous :", buttonsJson: [{ id: "jeunes", title: "Jeunes" }, { id: "femmes", title: "Femmes" }, { id: "commercants", title: "Commerçants" }] },
|
| 60 |
+
{ dayNumber: 4, exerciseType: "TEXT", lessonText: "Ton client a un problème. Quel est son plus grand problème ? Parle à 3 personnes aujourd'hui. Pose cette question. Écoute sans expliquer ton produit.", exercisePrompt: "Quel est le problème N°1 que tes clients t'ont partagé ?" },
|
| 61 |
+
{ dayNumber: 5, exerciseType: "BUTTON", lessonText: "À quel moment ton client a ce problème ?", exercisePrompt: "Choisis le moment d'apparition du problème :", buttonsJson: [{ id: "matin_midi", title: "Matin ou Midi" }, { id: "soir", title: "Le Soir" }, { id: "tout_le_temps", title: "Tout le temps" }] },
|
| 62 |
+
{ dayNumber: 6, exerciseType: "TEXT", lessonText: "Avant toi, il faisait comment ?", exercisePrompt: "Donne-moi 2 solutions que ton client utilisait avant de te connaître :" },
|
| 63 |
+
{ dayNumber: 7, exerciseType: "TEXT", lessonText: "Explique ta solution en mots simples. Pas compliqué.", exercisePrompt: "Décris-moi ton offre très simplement en une phrase :" },
|
| 64 |
+
{ dayNumber: 8, exerciseType: "BUTTON", lessonText: "Tu ne peux pas promettre tout. Choisis une seule force.", exercisePrompt: "Quelle est ta promesse principale ?", buttonsJson: [{ id: "rapide", title: "Rapide" }, { id: "moins_cher", title: "Moins cher" }, { id: "fiable_proche", title: "Fiable / Proche" }] },
|
| 65 |
+
{ dayNumber: 9, exerciseType: "TEXT", lessonText: "Parle à 5 personnes. Dis ta phrase. Combien disent OUI ?", exercisePrompt: "Combien t'ont dit OUI ? (Envoie juste un chiffre)" },
|
| 66 |
+
{ dayNumber: 10, exerciseType: "TEXT", lessonText: "Ton prix doit couvrir tes coûts. Note 2 dépenses importantes.", exercisePrompt: "Quelles sont tes 2 plus grosses dépenses pour ce projet ?" },
|
| 67 |
+
{ dayNumber: 11, exerciseType: "BUTTON", lessonText: "Pourquoi toi et pas un autre ?", exercisePrompt: "Quel est ton vrai avantage concurrentiel ?", buttonsJson: [{ id: "qualite", title: "Qualité" }, { id: "rapidite", title: "Rapidité" }, { id: "confiance", title: "Confiance" }] },
|
| 68 |
+
{ dayNumber: 12, exerciseType: "AUDIO", lessonText: "Maintenant tu es prêt. Dis en 30 secondes : Je suis... J'aide... Parce que... Je vends... À...", exercisePrompt: "C'est l'heure du test ! Envoie-moi un audio avec ton Mini Pitch de 30 secondes :" },
|
| 69 |
+
]
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
});
|
| 73 |
+
|
| 74 |
+
// Seed WOLOF track
|
| 75 |
+
await prisma.track.create({
|
| 76 |
+
data: {
|
| 77 |
+
title: "Comprendre Son Business (WOLOF)",
|
| 78 |
+
description: "Apprenez à définir, tester et vendre votre projet en 12 leçons.",
|
| 79 |
+
duration: 12,
|
| 80 |
+
language: "WOLOF",
|
| 81 |
+
days: {
|
| 82 |
+
create: [
|
| 83 |
+
{ dayNumber: 1, exerciseType: "AUDIO", lessonText: "Tey, danuy tàmbalee ak lu yomb. Nit ñu bari dañuy wax : dama def commerce. Waaye loolu amul solo. Wax ma leer : Yaay jàppalé KAN, mu def LAN, te naka nga amee xaalis. Misaal : Damaa jaay jus bissap ci taalibe yu université. Léegi sa waxtu la. Wax sa activité ci 15 seconde.", exercisePrompt: "Yónnee ma ab kàddu (audio) walla message bu gatt ngir wax sa mbir :" },
|
| 84 |
+
{ dayNumber: 2, exerciseType: "AUDIO", lessonText: "Kiliifa bi du jënd sa produit rek. Mu jënd ab résultat. Du jënd savon rek. Mu jënd set. Dem laaj 2 kiliifa : Lu tax nga jënd lii ? Déggal bu baax li ñuy wax.", exercisePrompt: "Yónnee ma audio ngir tënk ñaari tontu ya." },
|
| 85 |
+
{ dayNumber: 3, exerciseType: "BUTTON", lessonText: "Su nga jaay ci ñépp, doo jaay ci kenn. Tànnal benn kiliifa bu mag. Kan moo gën a soxla sa produit ?", exercisePrompt: "Tànnal sa kiliifa bu mag ci suuf :", buttonsJson: [{ id: "ndaw_nyi", title: "Ndaw ñi / Jeunes" }, { id: "jigeen_nyi", title: "Jigeen ñi / Femmes" }, { id: "jaaykat_yi", title: "Jaaykat yi / Comms" }] },
|
| 86 |
+
{ dayNumber: 4, exerciseType: "TEXT", lessonText: "Sa kiliifa am na jafe jafe. Lan mooy jafe jafe bu gën a rëy ? Dem waxtaan ak 3 nit. Laaj leen. Bul def publicité.", exercisePrompt: "Lan mooy jafe jafe bu gën a mag bi sa kiliifa yi am ?" },
|
| 87 |
+
{ dayNumber: 5, exerciseType: "BUTTON", lessonText: "Kañ la jafe jafe bi di ñëw ?", exercisePrompt: "Tànnal jamono ji jafe jafe bi di faral di am :", buttonsJson: [{ id: "suba_bëccëg", title: "Suba walla Bëccëg" }, { id: "ngoon", title: "Ngoon / Guddi" }, { id: "saa_su_ne", title: "Saa su nekk" }] },
|
| 88 |
+
{ dayNumber: 6, exerciseType: "TEXT", lessonText: "Balaa yaw, naka la daan def ?", exercisePrompt: "Wax ma ñaari pexe yi kiliifa bi daan jëfandikoo balaa xam sa produit :" },
|
| 89 |
+
{ dayNumber: 7, exerciseType: "TEXT", lessonText: "Wax sa solution ci wax yu yomb.", exercisePrompt: "Tënkal sa solution ci benn phrase bu yomb :" },
|
| 90 |
+
{ dayNumber: 8, exerciseType: "BUTTON", lessonText: "Bul promettre lépp. Tànnal benn doole.", exercisePrompt: "Lan mooy sa dige bu mag ?", buttonsJson: [{ id: "gaaw", title: "Dafa gaaw" }, { id: "yomb", title: "Dafa yomb / Prix" }, { id: "woor", title: "Dafa woor" }] },
|
| 91 |
+
{ dayNumber: 9, exerciseType: "TEXT", lessonText: "Dem waxtaan ak 5 nit. Ñaata ñu wax WAAN ?", exercisePrompt: "Ñaata nit ñoo wax WAAN ? (Bind ma chiffre bi rek)" },
|
| 92 |
+
{ dayNumber: 10, exerciseType: "TEXT", lessonText: "Sa priix war na japp sa dépense. Bind ñaari dépense.", exercisePrompt: "Bind ma ñaari dépense yu gën a rëy ci sa mbir :" },
|
| 93 |
+
{ dayNumber: 11, exerciseType: "BUTTON", lessonText: "Lu tax yaw te du keneen ?", exercisePrompt: "Lan nga gën a mën ci ñeneen ñi ?", buttonsJson: [{ id: "baax", title: "Dafa baax" }, { id: "gaaw", title: "Dafa gaaw" }, { id: "koolute", title: "Kooluté / Confiance" }] },
|
| 94 |
+
{ dayNumber: 12, exerciseType: "AUDIO", lessonText: "Léegi nga hazır. Wax ci 30 seconde : Man ma... Damaa jàppalé... Ndax... Damaa jaay... Ci...", exercisePrompt: "Yónnee ma sa Pitch bu gatt ci 30 seconde :" },
|
| 95 |
+
]
|
| 96 |
+
}
|
| 97 |
+
}
|
| 98 |
+
});
|
| 99 |
+
|
| 100 |
+
await scheduleMessage(user.id, "✅ Seeding terminé ! Les 2 modules (FR + WOLOF) sont en base. Envoie INSCRIPTION pour commencer.");
|
| 101 |
} catch (err: any) {
|
| 102 |
console.error('Seed Error:', err);
|
| 103 |
await scheduleMessage(user.id, `❌ Erreur de seed : ${err.message}`);
|
apps/whatsapp-worker/Dockerfile
CHANGED
|
@@ -9,4 +9,8 @@ RUN pnpm --filter @repo/database generate || npx prisma generate --schema=packag
|
|
| 9 |
|
| 10 |
RUN pnpm --filter @repo/database build
|
| 11 |
RUN pnpm --filter whatsapp-worker build
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
CMD ["pnpm", "--filter", "whatsapp-worker", "start"]
|
|
|
|
| 9 |
|
| 10 |
RUN pnpm --filter @repo/database build
|
| 11 |
RUN pnpm --filter whatsapp-worker build
|
| 12 |
+
|
| 13 |
+
# Force IPv4 DNS resolution to fix ENOTFOUND graph.facebook.com on cloud deployments
|
| 14 |
+
ENV NODE_OPTIONS="--dns-result-order=ipv4first"
|
| 15 |
+
|
| 16 |
CMD ["pnpm", "--filter", "whatsapp-worker", "start"]
|