Using the SDK

Getting started with our SDK

Basic example

Since we provide the entire UI and streaming for you, you only have to listen for messages from the front end and send messages from your backend. Here's a dead simple example of a ping-pong app. Indeed, you can make much more complex applications with multiple agents streaming in real time.

import { Project } from 'agentlabs-sdk';

const project = new Project({
    projectId: 'you-project-id',
    secret: 'your-secret',
    url: 'provided-in-your-console'
});

const agent = project.agent('agent-id');

project.onChatMessage((message) => {
  if (message.text === 'ping') {
     agent.send({
        conversationId: message.conversationId,
        text: 'pong'
     })
  } else {
     agent.send({
        conversationId: message.conversationId,
        text: 'I do not understand'
     })
  }
});

project.connect()

Next

Learn more about our core concepts and follow some recipes to get started.

Core ConceptsRecipes

Last updated