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

cdial-agent-widget-sdk

v1.5.0

Published

<!-- # Cdial Agent PRO Widget SDK --> # INDIGENIUS AGENT PRO

Downloads

15

Readme

INDIGENIUS AGENT PRO

CdialWidget is a powerful SDK for integrating AI Agent call widget into your web application, offering functionalities to easily initiate and manage calls with your AI-powered customer service agents.

Installation

To use the SDK in your project, you can either:

  1. Install via npm (recommended for modern JavaScript applications)

    npm install cdial-agent-widget-sdk
  2. Include the UMD build via CDN (for legacy support)

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sdk.umd.js"></script>
  3. Include the official url (for legacy support)

    <script
      type="module"
      src="https://widget.indigenius.ai/v1/index.js"
    ></script>

Quick Start

HTML Integration

You can integrate the widget into your HTML file with the following steps:

  1. Add the <indigenius-convai> component to your HTML body to display the widget.
  2. Include the SDK script (either from a CDN or local build).
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My Webapp</title>
  </head>
  <body>
    <h1>Welcome to my random HTML site...</h1>

    <!-- Add the widget component -->
    <indigenius-convai agent-id="your-agent-id"></indigenius-convai>

    <!-- Add the SDK script (local or CDN) -->
    <script
      type="module"
      src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sdk.umd.js"
    ></script>

    <script defer>
      // Initialize event listeners
      window.addEventListener("load", () => {
        widget.on("dialing", () => {
          console.log("Dialing detected");
        });
        widget.on("connected", () => {
          console.log("Connected detected");
        });
        widget.on("ended", () => {
          console.log("Ended detected");
        });
        widget.on("error", (err) => {
          console.error("Error:", err);
        });
      });
    </script>
  </body>
</html>

Framework Usage

Initialize the Widget

The init method is used to initialize the widget with an agent ID. Ensure that you provide a valid agentId when initializing the widget.

import { CdialWidget } from "cdial-agent-widget-sdk";

const widget = new CdialWidget({
  agentId: "your-agent-id",
});

widget.init().then(() => {
  console.log("Widget initialized");
});

The init method loads the widget's theme, sets up elements, and attaches them to the page if you want to use the dashboard customized flo0ating UI.

Toggle Call

Use toggleCall to start or end a call. This method toggles the widget between the "call in progress" state and the "idle" state.

widget.toggleCall(); // Starts or ends the call based on the current state

You can listen to events related to call state changes.

Event Listeners

The SDK supports various events that you can listen to for user interaction or state changes.

Example: Listening to Call Start and End Events

import { on } from "cdial-agent-widget-sdk";

// Listen to call started
on("callStarted", () => {
  console.log("Call has started");
});

// Listen to call ended
on("callEnded", () => {
  console.log("Call has ended");
});

Destroy the Widget

To clean up and remove the widget from the page, use the destroy method. This is useful if you need to remove the widget entirely after use.

widget.destroy();

This method will remove all elements created by the widget and stop any ongoing call operations.


Full Example

Here’s a complete example of how to use the widget:


React Integration (Simplified Example)

Here's how to use the widget in a basic React application:

1. Install the SDK

npm install cdial-agent-widget-sdk

2. Use in React Component

// App.jsx or App.js
import { useEffect, useRef, useState } from "react";
import { CdialWidget } from "cdial-agent-widget-sdk";

function App() {
  const widgetRef = useRef(null);
  const [callState, setCallState] = useState("idle");

  useEffect(() => {
    const widget = new CdialWidget({ agentId: "your-agent-id" });
    widgetRef.current = widget;

    widget.on("dialing", () => setCallState("dialing"));
    widget.on("connected", () => setCallState("connected"));
    widget.on("ended", () => setCallState("ended"));
    widget.on("error", console.error);

    widget.init();

    return () => {
      widget.destroy?.();
    };
  }, []);

  const toggleCall = () => {
    widgetRef.current?.toggleCall?.();
  };

  const getButtonText = () => {
    switch (callState) {
      case "dialing":
        return "Dialing...";
      case "connected":
        return "End Call";
      default:
        return "Start Call";
    }
  };

  return (
    <div style={{ padding: "2rem", fontFamily: "Arial" }}>
      <h2>Cdial Widget Call Button</h2>
      <button onClick={toggleCall}>{getButtonText()}</button>
    </div>
  );
}

export default App;

Methods

init()

Initializes the widget with the given agentId and sets up the UI.

Returns: Promise<void>

toggleCall()

Starts or ends a call based on the current widget state.

Returns: void

destroy()

Destroys the widget, removing all associated elements and cleaning up resources.

Returns: void


Events

The widget emits several events that you can listen to for customizing your application's behavior. Below is a list of available events, their descriptions, and usage examples.

📡 dialing

Emitted when the widget starts attempting to connect to the AI agent.

Example:

myCdialWidget.on("dialing", () => {
  console.log("Dialing detected");
});

🔗 connected

Emitted when the connection to the AI agent is successfully established.

Example:

myCdialWidget.on("connected", () => {
  console.log("Connected detected");
});

ended

Emitted when the call has ended or was terminated.

Example:

myCdialWidget.on("ended", () => {
  console.log("Ended detected");
});

🎙️ transcript

Emitted whenever a new piece of speech is transcribed during the call.

Payload: text (string) – the transcribed voice input.

Example:

myCdialWidget.on("transcript", (text) => {
  console.log("Transcript Received:", text);
});

⚠️ error

Emitted if there is an internal error during the operation of the widget.

Payload: err (Error or string) – details about the error that occurred.

Example:

myCdialWidget.on("error", (err) => {
  console.error("Error:", err);
});

You can register these event listeners after the widget has loaded:

<script defer>
  window.addEventListener("load", () => {
    myCdialWidget.on("dialing", () => {
      console.log("Dialing detected");
    });

    myCdialWidget.on("connected", () => {
      console.log("Connected detected");
    });

    myCdialWidget.on("ended", () => {
      console.log("Ended detected");
    });

    myCdialWidget.on("transcript", (text) => {
      console.log("Transcript Received:", text);
    });

    myCdialWidget.on("error", (err) => {
      console.error("Error:", err);
    });
  });
</script>

License

This SDK is released under the MIT License. See LICENSE for more details.