Ping-Pong
Let's start with a ping pong
Last updated
import { Project } from 'agentlabs-sdk';
const project = new Project({
projectId: 'you-project-id',
secret: 'your-secret',
});
const agent = project.agent('agent-id');from agentlabs.chat import IncomingChatMessage, MessageFormat
from agentlabs.project import Agent, Project
project = Project(
project_id='your-project-id',
secret='your-secret'
)
agent = project.agent('agent-id')import { Project } from 'agentlabs-sdk';
const project = new Project({
projectId: 'you-project-id',
secret: 'your-secret',
});
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 did not get that'
})
}
})from agentlabs.chat import IncomingChatMessage, MessageFormat
from agentlabs.project import Agent, Project
project = Project(
project_id='your-project-id',
secret='your-secret'
)
agent = project.agent('agent-id')
def handle_message(message: IncomingChatMessage):
if message.text == 'ping':
agent.send(
conversation_id=message.conversation_id,
text="pong"
)
else:
agent.send(
conversation_id=message.conversation_id,
text="I did not understand"
)
project.on_chat_message(handle_message)import { Project } from 'agentlabs-sdk';
const project = new Project({
projectId: 'you-project-id',
secret: 'your-secret',
});
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 did not get that'
})
}
})
project.connect()from agentlabs.chat import IncomingChatMessage, MessageFormat
from agentlabs.project import Agent, Project
project = Project(
project_id='your-project-id',
secret='your-secret'
)
agent = project.agent('agent-id')
def handle_message(message: IncomingChatMessage):
if message.text == 'ping':
agent.send(
conversation_id=message.conversation_id,
text="pong"
)
else:
agent.send(
conversation_id=message.conversation_id,
text="I did not understand"
)
project.on_chat_message(handle_message)
project.connect()
project.wait();