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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hamsa-ai/voice-agents-sdk

v0.2.2

Published

Hamsa AI - Voice Agents JavaScript SDK

Downloads

192

Readme

Hamsa Voice Agents Web SDK

Hamsa Voice Agents Web SDK is a JavaScript library for integrating voice agents from https://dashboard.tryhamsa.com. This SDK provides a seamless way to incorporate voice interactions into your web applications.

Installation

Install the SDK via npm:

npm i @hamsa-ai/voice-agents-sdk

Usage

First, import the package in your code:

import { HamsaVoiceAgent } from '@hamsa-ai/voice-agents-sdk'

Initialize the SDK with your API key. To obtain your first API key, visit https://dashboard.tryhamsa.com

const agent = new HamsaVoiceAgent(API_KEY);

Start a Conversation with an Existing Agent

Start a conversation with an existing agent by calling the "start" function. You can create and manage agents in our Dashboard or using our API (see: https://docs.tryhamsa.com):

agent.start({
    agentId: YOUR_AGENT_ID,
    params: {
        param1: "NAME",
        param2: "NAME2"
    }
});

When creating an agent, you can add parameters to your pre-defined values. For example, you can set your Greeting Message to: "Hello {{name}}, how can I help you today?" and pass the "name" as a parameter to use the correct name of the user.

Pause/Resume a Conversation

To pause the conversation, call the "pause" function. This will prevent the SDK from sending or receiving new data until you resume the conversation:

agent.pause();

To resume the conversation:

agent.resume();

End a Conversation

To end a conversation, simply call the "end" function:

agent.end();

Events

During the conversation, the SDK emits events to update your application about the conversation status.

Conversation Status Events

agent.on("callStarted", () => { console.log("Conversation has started!"); });
agent.on("callEnded", () => { console.log("Conversation has ended!"); });
agent.on("callPaused", () => { console.log("The conversation is paused"); });
agent.on("callResumed", () => { console.log("Conversation has resumed"); });

Agent Status Events

agent.on("speaking", () => { console.log("The agent is speaking"); });
agent.on("listening", () => { console.log("The agent is listening"); });

Conversation Script Events

agent.on("transcriptionReceived", (text) => { console.log("User speech transcription received", text); });
agent.on("answerReceived", (text) => { console.log("Agent answer received", text); });

Error Events

agent.on("closed", () => { console.log("Conversation was closed"); });
agent.on("error", (e) => { console.log("Error was received", e); });