fix(voice-call): speak inbound greeting for twilio answered calls

This commit is contained in:
Xinhua Gu
2026-02-27 21:36:31 +01:00
committed by Peter Steinberger
parent b8b8a5f314
commit fe4c627432
2 changed files with 21 additions and 24 deletions

View File

@@ -111,28 +111,31 @@ describe("CallManager", () => {
expect(manager.getCallByProviderCallId("request-uuid")).toBeUndefined(); expect(manager.getCallByProviderCallId("request-uuid")).toBeUndefined();
}); });
it("speaks initial message on answered for notify mode (non-Twilio)", async () => { it.each(["plivo", "twilio"] as const)(
const { manager, provider } = createManagerHarness(); "speaks initial message on answered for notify mode (%s)",
async (providerName) => {
const { manager, provider } = createManagerHarness({}, new FakeProvider(providerName));
const { callId, success } = await manager.initiateCall("+15550000002", undefined, { const { callId, success } = await manager.initiateCall("+15550000002", undefined, {
message: "Hello there", message: "Hello there",
mode: "notify", mode: "notify",
}); });
expect(success).toBe(true); expect(success).toBe(true);
manager.processEvent({ manager.processEvent({
id: "evt-2", id: `evt-2-${providerName}`,
type: "call.answered", type: "call.answered",
callId, callId,
providerCallId: "call-uuid", providerCallId: "call-uuid",
timestamp: Date.now(), timestamp: Date.now(),
}); });
await new Promise((resolve) => setTimeout(resolve, 0)); await new Promise((resolve) => setTimeout(resolve, 0));
expect(provider.playTtsCalls).toHaveLength(1); expect(provider.playTtsCalls).toHaveLength(1);
expect(provider.playTtsCalls[0]?.text).toBe("Hello there"); expect(provider.playTtsCalls[0]?.text).toBe("Hello there");
}); },
);
it("rejects inbound calls with missing caller ID when allowlist enabled", () => { it("rejects inbound calls with missing caller ID when allowlist enabled", () => {
const { manager, provider } = createManagerHarness({ const { manager, provider } = createManagerHarness({

View File

@@ -166,12 +166,6 @@ export class CallManager {
return; return;
} }
// Twilio has provider-specific state for speaking (<Say> fallback) and can
// fail for inbound calls; keep existing Twilio behavior unchanged.
if (this.provider.name === "twilio") {
return;
}
void this.speakInitialMessage(call.providerCallId); void this.speakInitialMessage(call.providerCallId);
} }