Most "add an AI assistant to my app" tutorials stop at the demo. They show you how to call an LLM and print the response, then leave the production plumbing — error mapping, input validation, retry handling, observability — as an exercise for the reader. This example takes the opposite path: a small Express app that does one thing well, exposes it as a clean HTTP endpoint, and maps Telnyx SDK errors to the right HTTP status codes from the first request.

The full code is in the telnyx-code-examples repository under chat-with-ai-assistant-nodejs. It is roughly 80 lines of JavaScript including imports, comments, and a /health check.

What the App Does

The app exposes one chat endpoint and one health endpoint:

POST /chat — sends a message to a Telnyx AI Assistant and returns its response