export function escapeXmlValue(str: string): string {
  return str
    .replace(/&/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    .replace(/"/g, '&quot;');
}

export function generateHangupTwiML(message?: string): string {
  const safeMsg = escapeXmlValue(message || 'Thank you for calling. Goodbye!');
  return `<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say voice="Polly.Joanna" language="en-US">${safeMsg}</Say>
  <Hangup/>
</Response>`;
}
