separated in modules
This commit is contained in:
30
src/modules/1-intake/handlers/sim.js
Normal file
30
src/modules/1-intake/handlers/sim.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import crypto from "crypto";
|
||||
import { resolveTenantId } from "../../2-identity/services/pipeline.js";
|
||||
import { processMessage } from "../../2-identity/services/pipeline.js";
|
||||
|
||||
export async function handleSimSend(body) {
|
||||
const { chat_id, from_phone, text } = body || {};
|
||||
if (!chat_id || !from_phone || !text) {
|
||||
return { status: 400, payload: { ok: false, error: "chat_id, from_phone, text are required" } };
|
||||
}
|
||||
|
||||
const provider = "sim";
|
||||
const message_id = crypto.randomUUID();
|
||||
const tenantId = await resolveTenantId({
|
||||
chat_id,
|
||||
tenant_key: body?.tenant_key,
|
||||
to_phone: body?.to_phone,
|
||||
});
|
||||
|
||||
const result = await processMessage({
|
||||
tenantId,
|
||||
chat_id,
|
||||
from: from_phone,
|
||||
text,
|
||||
provider,
|
||||
message_id,
|
||||
});
|
||||
|
||||
return { status: 200, payload: { ok: true, run_id: result.run_id, reply: result.reply } };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user