DEV Community

anusha
anusha

Posted on

I Built a Web Chatbot with a Telnyx AI Assistant

Most AI assistant demos jump straight to voice. Voice is great, but a web chat is often the cleanest place to start.

You can prove the core idea quickly: configure an assistant in the Portal, send it user messages through the API, and render the response in your own interface.

The Telnyx code example for this is:

https://github.com/team-telnyx/telnyx-code-examples/tree/main/chat-with-ai-assistant-python

The Idea

The assistant lives in Telnyx. The UI lives in your app.

That split is useful. Product teams can tune the assistant instructions in the Telnyx Mission Control Portal, while developers keep full control over the frontend, authentication, routing, styling, logging, and product-specific behavior.

For this demo, I used the assistant as a Telnyx Chatbot. It answers questions like what Telnyx does, what a Frankenstack is, and how AI Assistants fit into programmable communications.

The Flow

The app is a small Flask server with a browser UI.

When the page loads, the backend creates a Telnyx conversation. When the user sends a message, the backend sends that message to the Assistant Chat API. The assistant response comes back as text and the UI renders it in the chat window.

The important part is that the API key stays on the server. The browser only talks to the Flask app.

Why This Demo Works

This is a good first AI Assistant project because there is no phone number setup, no webhook tunnel, and no call-control state machine. You can focus on the assistant lifecycle:

create conversation
send message
render response
continue conversation
Enter fullscreen mode Exit fullscreen mode

That makes it easier to explain the difference between a Portal-managed assistant and a raw model completion. The assistant has configuration, instructions, conversation context, and product-level settings. Your app just decides where and how that assistant shows up.

Running It

git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/chat-with-ai-assistant-python
cp .env.example .env
pip install -r requirements.txt
python app.py
Enter fullscreen mode Exit fullscreen mode

Environment:

TELNYX_API_KEY=your_telnyx_api_key
AI_ASSISTANT_ID=your_ai_assistant_id
PORT=5000
Enter fullscreen mode Exit fullscreen mode

Open the local app and ask:

What is Telnyx?
Enter fullscreen mode Exit fullscreen mode

Then ask:

What is a Frankenstack?
Enter fullscreen mode Exit fullscreen mode

Those two questions make the demo easy to understand. Telnyx is the integrated communications and AI platform; a Frankenstack is what happens when teams stitch together separate vendors for telephony, speech-to-text, LLMs, text-to-speech, messaging, analytics, and workflows.

What I Would Add Next

For a real product, I would add user accounts, persistent conversation history, analytics, rate limits, and a handoff path to a human or support workflow. If the same assistant also powers voice or messaging, I would keep the assistant's core instructions consistent and let each channel handle its own UX.

That is the nice part of this pattern: one assistant can power multiple user experiences, and the app decides how the experience feels.

Resources

Top comments (1)

Collapse
 
alexshev profile image
Alex Shev

The part I always look for in chatbot builds is the handoff path. A demo can answer happy-path questions, but production needs escalation, transcript quality, retry behavior, and a clean way to tell when the assistant should stop guessing.