This SDK makes it easy to connect a voice AI bot to a dTelecom room. It builds a streaming pipeline from participants’ audio: speech recognition → LLM text processing → speech synthesis, and publishes the response back to the room as an Opus track.
- Connect a bot to a dTelecom/LiveKit room via
URL + ROOM_TOKEN. - Processing pipeline: STT (Deepgram) → LLM (ChatGPT) → TTS (Deepgram).
- Multi‑participant support: the bot listens to participants’ microphones and replies with synthesized voice.
- Flexible extensibility via
SpeechToText,TextProcessor,TextToSpeechinterfaces and agent constructor options.
- Go 1.24+
- dTelecom/LiveKit account and a room token (
ROOM_TOKEN). - API keys:
DEEPGRAM_API_KEY— for Deepgram STT/TTSCHATGPT_API_KEY— for the text processor (ChatGPT)
Add the module to your project:
go get github.com/dTelecom/sdk-ai-botIf your project fails to resolve Deepgram due to forked modules, add this replace to your project’s go.mod:
replace github.com/deepgram/deepgram-go-sdk/v3 => github.com/dTelecom/deepgram-go-sdk/v3 v3.5.1-0.20251012194105-df6ec5cf4d79This SDK already uses that replace internally; adding it to your app ensures consistent resolution when your build tooling vendors or overrides module graph.
Note: the included examples use godotenv and expect a .env file for convenience. Your own application can source these values any way you prefer (a .env file is not required).
Create a .env file in the example directory (or your app root) or set environment variables directly:
DTELECOM_URL=... # your dTelecom server URL
ROOM_TOKEN=... # dTelecom room token
DEEPGRAM_API_KEY=... # Deepgram API key
CHATGPT_API_KEY=... # OpenAI (ChatGPT) API keyThe simplest example is in examples/default_agent.
Run:
cd examples/default_agent
go run .Examples read the URL from the DTELECOM_URL env var. Set it to your own deployment.
What the example does:
- Loads
.envviagodotenv(examples) and initializes the Deepgram SDK (logging). - Creates
agent.New(logger)with default pipeline (Deepgram STT, ChatGPT, Deepgram TTS). - Calls
a.Connect(url, ROOM_TOKEN), publishes a local Opus track, and starts listening to participants.
examples/agent_with_prompt shows how to pass your own TextProcessor to agent.New via options:
textProcessor, _ := buildTextProcessor(logger) // ChatGPT with SystemPrompt
a, _ := agent.New(logger, agent.WithTextProcessor(textProcessor))
a.Connect(os.Getenv("DTELECOM_URL"), os.Getenv("ROOM_TOKEN"))The buildTextProcessor function configures a system prompt and uses CHATGPT_API_KEY.
examples/pipeline demonstrates a pure local pipeline without connecting to a room: microphone → STT → ChatGPT → TTS → local playback.
Run:
cd examples/pipeline
go run .type Agent struct { /* ... */ }
func New(logger *zap.Logger, options ...Option) (*Agent, error)
func (a *Agent) Connect(url, token string) errorNew— builds the pipeline from components (Deepgram STT, ChatGPT, Deepgram TTS by default) or accepts your implementations via options.Connect— connects to the room, publishes a local Opus track, and subscribes to participants’ audio. Each participant’s audio flows through the pipeline; responses are synthesized and sent back to the room.
type Pipeline struct { /* ... */ }
func NewPipeline(stt SpeechToText, tp TextProcessor, tts TextToSpeech) *Pipeline
func (p *Pipeline) Start(ctx context.Context) (<-chan AudioChunk, error)
func (p *Pipeline) AddParticipant(ctx context.Context, name string, chunks <-chan AudioChunk) errorStart— starts processing and returns the bot’s audio chunk channel (Opus or PCM depending on TTS/transcoder).AddParticipant— adds a participant: audio stream → STT → phrase accumulation via speech start/end control tokens → questions go toTextProcessor.
type SpeechToText interface {
Transcribe(ctx context.Context, r <-chan AudioChunk) (<-chan SpeechChunk, error)
}
type TextProcessor interface {
Process(ctx context.Context, question <-chan TextChunk) (<-chan TextChunk, error)
}
type TextToSpeech interface {
Synthesize(ctx context.Context, text <-chan TextChunk) (<-chan AudioChunk, error)
}Implement these interfaces to swap out Deepgram/ChatGPT for other providers. For the agent, use options:
agent.WithSTT(customSTT)
agent.WithTextProcessor(customTP)
agent.WithTTS(customTTS)The project includes unit and integration tests for STT/TTS components and utilities. Run:
go test ./...Integration tests for Deepgram and transcoders may require valid API keys and audio files from test_data.
This project is licensed under the MIT License. See the LICENSE file for details.