Installation

Install the Ponder web sdk using NPM

npm install @ponderai/web

Ponder

The Ponder class is the main class that exposes all Ponder’s functionality

example
const ponder = new Ponder({ assistantId: assistantId, host: host })

Params

assistantId
string

the id of the assistant that is created on the dashboard

host
string

url of the Ponder backend, usually https://api.useponder.ai unless self hosted

instructions
string

instructions for the agent, these get added to the system prompt from the dashboard

actions
array

a list of actions / function the agent can call. format is the same as react sdk - refer it for schema

Properties

connect
function

starts a web call

example
ponder.connect()
disconnect
function

stops a web call

example
ponder.disconnect()
onConnected
callback

callback function called when the call is connected and the agent is listening

example
onConnected(() => {console.log("ponder connected")})
onDisconnected
callback

callback function called when the call is disconnected and the agent is no longer listening

example
onDisconnected(() => {console.log("ponder disconnected")})
onSpeechStart
function

callback function for whenever user speech start is detected
does not have any arguments

example
onSpeechStart(() => {console.log("speech started")})
onSpeechEnd
function

callback function for whenever user is done speaking
does not have any arguments

example
onSpeechEnd(() => {console.log("speech ended")})
onMessage
function

callback for whenever there is a new message added to the conversation
for example when the user’s speech is transcribed, or when the agent’s response is recieved

example
onMessage((message) => {console.log(message)})
// {"role": "user", "text": "Hello there"}
onFunctionCall
function

callback for whenever the agent decides to call a function
has the name - function name and args - arguments of the function as parameters

example
onFunctionCall((name, args) => {console.log(name, args)})