We're using Debugging Events Webhook to send Twilio Error logs to CloudWatch so we can better summarize and analyze errors from Twilio.
We're not getting the complete error message for Flex UI errors (45600) though. For example, the webhook only receives the following from Twilio (ids are redacted):
{
"Payload": {
"resource_sid": "WK...",
"service_sid": "WS...",
"error_code": "45600"
},
"Level": "ERROR",
"Timestamp": "2024-11-04T15:31:10.479061Z",
"PayloadType": "application/json",
"AccountSid": "AC...",
"Sid": "NO..."
}
But for the same Error Sid, we can see a complete JavaScript error with stack trace in the Twilio Console:
(I'm not concerned about the Flex UI error in itself, but the fact that the complete error message, highlighted in the screenshot above, is only available in the Twilio Console and not in the event sent to the webhook)
How can we receive the complete error message in the Debugging Events Webhook too?
Using Twilio Event Streams solves the issue. The body now contains the complete error message for Flex UI errors (45600) under data.payload.message.
Example:
{
"specversion": "1.0",
"type": "com.twilio.error-logs.error.logged",
"source": "/v1/Alerts/NO...",
"id": "NO...",
"dataschema": "https://events-schemas.twilio.com/ErrorLogs.Error/1",
"datacontenttype": "application/json",
"time": "2025-02-07T21:27:20.288Z",
"data": {
"date_created": "2025-02-07T21:27:20.288204Z",
"payload": "{\"error_code\":45600,\"message\":\"\n## Error: \"no active call\"\n\n### LOG LINE\n```\n2/7/2025, 4:27:20 PM - WorkerActions.AcceptTask: no active call\n```\n\n### STACK TRACE\n```\nError: no active call\n at new n (https://assets.flex.twilio.com/releases/flex-ui/2.10.1/twilio-flex.unbundled-react.min.js:387:4579826)\n at e.createAndProcessError (https://assets.flex.twilio.com/releases/flex-ui/2.10.1/twilio-flex.unbundled-react.min.js:387:4582940)\n at https://assets.flex.twilio.com/releases/flex-ui/2.10.1/twilio-flex.unbundled-react.min.js:387:4706673\n```\n\n### DETAILS\n```\n{\n \"message\": \"no active call\",\n \"type\": \"app\",\n \"context\": \"WorkerActions.AcceptTask\",\n \"severity\": \"normal\",\n \"twilioErrorCode\": 45600\n}\n```\n \"}",
"request_sid": "RQ...",
"correlation_sid": "WK...",
"service_sid": "WS...",
"product_name": "Flex",
"account_sid": "AC...",
"error_code": "45600",
"sid": "NO...",
"level": "ERROR"
}
}