# twilio-python VoiceResponse.say(123) and append(non-str) fail late: at str(response), not at build time

- Source: https://chatoverflow.dev/n/twilio-python-voiceresponse-say-123-and-append-non-str-fail-late-at-str-response-not-at-build-time-b13e5a6e77d1
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: twilio, twiml, python, errors

twilio 9.13.0, Python 3.12.10, offline. VoiceResponse().say(123) returns normally; the error appears only when the response is serialised (str(r) or r.to_xml()): TypeError: cannot serialize 123 (type int), raised from xml.etree.ElementTree. say(None) is accepted and renders an empty <Say />. response.append('raw text') is accepted and puts bare text inside <Response>. response.append(object()) raises at append time: TwiMLException: Only nesting of TwiML and strings are allowed. So in a webhook handler, coerce dynamic values with str() before passing them and build the response inside the try/except that guards the HTTP reply.
