Integrating Voice AI into Zalo OA and Telegram Bots: A Practical API Guide

Learn how to build voice-enabled bots for Zalo OA and Telegram using AIVISION's ASR, LLM, and TTS APIs. Practical steps, code examples, and optimization tips

In the digital age, users increasingly prefer communicating via voice rather than typing. Building a voice-enabled bot for Telegram or Zalo OA not only speeds up response times but also delivers a deeply personalized experience. This article provides a practical, technical roadmap for integrating AI into messaging channels, transforming them into smart virtual assistants capable of handling voice requests seamlessly.

Why Integrate Voice into Zalo OA and Telegram?

User behavior indicates that voice messages now account for a significant portion of traffic on major messaging platforms. However, most current chatbots still require users to manually transcribe voice notes or support only text-based input. To resolve this bottleneck, you need a voice assistant API capable of real-time Natural Language Processing (NLP) and Automatic Speech Recognition (ASR).

For businesses, automating voice-based intake reduces the workload on customer support teams. Instead of waiting for a typed reply, customers can simply speak their needs, and the system processes, responds, or routes the query instantly. This offers a clear competitive advantage when optimizing Customer Experience (CX) on popular platforms in Vietnam and internationally.

System Architecture and Core Components

To deploy an effective AI-integrated messaging system, you need to connect three main components: the Messaging Platform (Zalo OA/Telegram), the Processing Logic (Backend), and the AI Services (ASR/TTS/NLP).

  1. Audio Capture: When a user sends a voice message via Zalo OA or Telegram, your backend downloads the audio file (typically in .ogg or .amr format).
  2. Speech-to-Text (ASR): The audio file is sent to the Speech-to-Text API. This step converts speech into text, preserving semantics and industry-specific terminology.
  3. Semantic Processing (NLP/LLM): The transcribed text is passed to a Large Language Model to analyze intent and generate an appropriate response.
  4. Text-to-Speech (TTS): The response text is converted back into natural-sounding speech using the Text-to-Speech API.
  5. Response: The final audio file is sent back to the user via Zalo OA or Telegram.

Technical Guide with AIVISION APIs

Below are the specific steps to start building your Telegram voice bot or Zalo voice chatbot.

Step 1: Prepare API Key and Endpoint

AIVISION supports both REST API for batch tasks and WebSocket for real-time streaming. For voice messages on Zalo/Telegram, the REST API is the suitable choice due to its stability and ease of file handling.

import requests

url = "https://api.s2speech.com/v1/audio/transcriptions"
headers = {
  "Authorization": "Bearer YOUR_API_KEY",
  "Content-Type": "multipart/form-data"
}
files = {
  "file": ("voice_message.ogg", open("voice_message.ogg", "rb"), "audio/ogg"),
  "model": "aiv-stt-v1"
}
response = requests.post(url, headers=headers, files=files)
transcript = response.json().get("text")
print(transcript)

Step 2: Process Text with LLM

Once you have the transcript from the ASR step, call the chatbot API to generate a response.

import openai

client = openai.OpenAI(
  api_key="YOUR_API_KEY",
  base_url="https://api.s2speech.com/v1"
)

completion = client.chat.completions.create(
  model="aivision-L1.0",
  messages=[
  {"role": "system", "content": "You are the friendly virtual assistant for [Brand Name]."},
  {"role": "user", "content": transcript}
  ]
)
reply_text = completion.choices[0].message.content

Step 3: Synthesize Speech (TTS)

Finally, convert the response into speech. AIVISION TTS supports natural Vietnamese voices and standard telephony formats (8 kHz G.711), ensuring clear audio quality even over mobile networks.

url = "https://api.s2speech.com/v1/audio/speech"
headers = {
  "Authorization": "Bearer YOUR_API_KEY"
}
data = {
  "model": "aiv-tts-S.1.0",
  "voice": "huy", # Select male or female voice
  "input": reply_text,
  "response_format": "mp3"
}
response = requests.post(url, headers=headers, json=data)
audio_data = response.content
# Send audio_data back to Zalo OA or Telegram

Optimization Tips for Performance and Experience

When deploying in production, there are several key technical points to ensure smooth operation:

  • Handling Code-Switching: Vietnamese users often mix English into their speech (e.g., "Send me this Excel file"). AIVISION's ASR model is trained to handle this code-switching effectively, minimizing recognition errors.
  • Audio Formats: Zalo OA typically sends .amr or .ogg files. You should verify the input format and convert it if necessary before sending it to the API to ensure compatibility.
  • Latency Optimization: To create a sense of quick response, use streaming where possible. However, for pre-recorded voice messages, latency primarily lies in the ASR and TTS processing. Using AIVISION's optimized REST endpoints helps reduce wait times.
  • Data Security: Ensure data is encrypted during transmission between your backend and the API. While AIVISION commits to protecting user data, the responsibility for securing the transmission line lies with the developer.

Technical Feature Comparison

Criteria Complex Custom Coding AIVISION API Integration
Deployment Time Long (requires model building) Fast (hours to days)
ASR Quality Depends on training data Avg. WER 10.53% on 4 Vietnamese test sets
Code-Switching Support Difficult Strong Vietnamese-English support
TTS Formats Limited Supports MP3, WAV, G.711 (Call Center)
Initial Cost High (Infrastructure, Personnel) Low (Free trial, no card required)

Advice for Developers

If you are just starting, begin with a simple conversation flow. For example: A customer asks, "How much is Product A?" The bot receives the voice, converts it to text, queries the database, and responds with voice. Once stable, expand to more complex tasks such as scheduling or handling complaints.

Leverage AIVISION's free trial to test the ASR model's accuracy with the actual voices of your potential customers. You can download sample audio files from Zalo OA and run them through the API to evaluate results before large-scale deployment.

Conclusion

Integrating voice AI into Zalo OA and Telegram Bots is no longer a luxury but an essential requirement for enhancing customer experience. With a complete suite of Speech-to-Text, Text-to-Speech, and LLM APIs, AIVISION helps you shorten development time and ensure the quality of natural Vietnamese language processing.

Start today by creating a free account to explore the potential of voice in your business. Don't miss the opportunity to turn your messaging channel into a multi-dimensional, efficient, and modern interaction platform.

Contact the AIVISION technical team if you need architecture consultation. Or visit the Blog for more in-depth articles on AI and natural language processing.

Frequently asked questions

Does the Zalo voice chatbot support Vietnamese mixed with English?

Yes. AIVISION's Speech-to-Text model is trained to handle code-switching effectively, accurately recognizing English words within Vietnamese speech and minimizing errors.

What is the cost to start testing the voice assistant API?

AIVISION offers a completely free trial for every account, with no credit card required. You can create an account at s2speech.com/signup and use the API immediately with a daily usage limit to check quality.

What is the speech recognition quality of AIVISION?

According to internal evaluations, AIVISION's ASR model achieves high accuracy with an average Word Error Rate (WER) of 10.53% across four Vietnamese test datasets, including both standard read speech and real business meeting recordings.

Do I need to train my own language model?

It is not mandatory. You can use the pre-built aivision-L1.0 model, which has strong capabilities in understanding and generating Vietnamese text. If you need deep industry-specific context, you can use prompt engineering or Retrieval-Augmented Generation (RAG) techniques combined with AIVISION's chat API.

Try AIVISION's Vietnamese speech AI

Speech-to-Text, Text-to-Speech and LLM, free.

Start free → Contact

By

Dr. Giang Vo — CEO, AIVISION

Dr. Giang Vo is the CEO of AIVISION, leading the development of s2speech — speech recognition, AI voices and a large language model for Vietnamese — and working with companies at home and abroad on their deployments.

0981 419 967 · giang.vo@aivgroups.com

#Voice AI#Zalo OA bot#Telegram bot#Speech-to-Text API#Text-to-Speech API#Vietnamese NLP#AIVISION API

Related articles