npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@frejun/teler

v1.0.10

Published

Teler Node SDK

Readme

Teler Node SDK

This Node library offers a lightweight and developer-friendly abstraction over the FreJun Teler API.

Requirements

  • Node.js 14.x or later
  • npm or yarn

Features

  • Initiate Calls: Easily start outbound calls using the Teler REST API.
  • Call Flows: Control what happens on the call using flows like Streaming, Playing Audio, and Hanging up.
  • Real-time Media Streaming: Stream call audio via WebSockets for Conversational AI, transcription, and insights.

Installation

Install the SDK using npm:

npm install @frejun/teler

Or using yarn:

yarn add @frejun/teler

Initiate call using Client

The Client is the main entry point to interact with the Teler API.

import { Client } from "@frejun/teler";

// Initialize the client with your API key
const client = new Client("YOUR_API_KEY");

// Initiate a call
const call = await client.calls.create({
    from_number: "+918065xxxx",
    to_number: "+919967xxxx",
    flow_url: "https://your-domain.com/flow",
    status_callback_url: "https://your-domain.com/receiver",
    record: true
});

Call Flows

When a call connects, Teler will fetch instructions from your flow_url. You can control the call using different actions:

Stream

Initiates bidirectional WebSocket streaming of the call's audio.

{
    "action": "stream",
    "ws_url": "wss://your-domain.com/stream",
    "sample_rate": "8k",
    "chunk_size": 400,
    "record": true,
}

Play

Plays an audio file to the caller.

{
    "action": "play",
    "media_url": "https://example.com/audio.mp3"
}

Hangup

Ends the call immediately.

{
    "action": "hangup"
}

Media Streaming

The library provides a powerful interface for integrating real-time call audio streams from Teler to your application via WebSockets.

StreamConnector

The StreamConnector lets you bridge the Teler call audio stream to your desired remote websocket endpoint (e.g., an AI agent). It handles message relaying between the two streams via pluggable handlers, making it highly customizable. It also handles graceful shutdown of the media streams in case of any unexpected errors.

It takes the following parameters:

  • streamType - Only StreamType.BIDIRECTIONAL is supported for now.
  • remoteUrl - The remote websocket URL where the call audio stream needs to be bridged.
  • callStreamHandler - An asynchronous StreamHandler function that handles incoming messages from the Teler call audio stream.
  • remoteStreamHandler - An asynchronous StreamHandler function that handles incoming messages from the remote audio stream (e.g., your AI agent).

Stream Handlers

A StreamHandler asynchronous function receives incoming messages over a WebSocket, processes them, and returns a tuple (for example, [StreamData, StreamOp]). The StreamOp value determines the action that the StreamConnector takes next.

  • callStreamHandler
    Receives audio data from the caller and forwards it to an AI model.

  • remoteStreamHandler
    Receives audio data from the remote endpoint (for example, an AI agent's response) and sends it back to the caller.

StreamOp

StreamOp can be one of the following:

  • StreamOp.RELAY
    Relays the message to the other stream. The first element of the returned tuple must contain the message to relay.

  • StreamOp.PASS
    Does not relay any message to the other stream. Any message included in the returned tuple is ignored.

  • StreamOp.STOP
    Stops both streams, ends the call, and exits gracefully. Any message included in the returned tuple is ignored.

StreamData

StreamData represents the data returned by a stream handler. It can be any of the following:

  • string
  • Buffer
  • Uint8Array
  • ArrayBuffer
  • Blob

Error Handling

teler throws typed exceptions that extend the base TelerException class, allowing you to handle errors precisely.

Exception Hierarchy

TelerException (base)
├── BadParametersException   (400)
├── UnauthorizedException    (401)
├── ForbiddenException       (403)
└── NotImplementedException  (501)

Exception Reference

| Exception | Code | Description | |-----------|------|-------------| | TelerException | 500 | Base exception, all SDK errors extend this | | BadParametersException | 400 | One or more request parameters are invalid | | UnauthorizedException | 401 | Invalid or missing API key | | ForbiddenException | 403 | Authenticated but not allowed to perform action | | NotImplementedException | 501 | Feature not yet implemented |

Properties

All exceptions expose:

  • message — human-readable error description
  • code — HTTP-style status code
  • name — exception class name (e.g. "BadParametersException")

BadParametersException additionally exposes:

  • param — the name of the invalid parameter