# Using the 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.

{% tabs %}
{% tab title="Typescript" %}

```typescript
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()
```

{% endtab %}

{% tab title="Python" %}

```python
from agentlabs.project import IncomingChatMessage, MessageFormat, Project

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 get that"
        )


project = Project(
        project_id='your-project-id',
        secret='your-secret',
        url='provided-in-your-console'
)

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

project.on_chat_message(handle_message)

project.connect()
project.wait();
```

{% endtab %}
{% endtabs %}

**Next**

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

{% content-ref url="/pages/R21c8oRX2G4mrfFHm89J" %}
[Core Concepts](/core-concepts/frontend-as-a-service.md)
{% endcontent-ref %}

{% content-ref url="/pages/ni06RdZYDOeTtrhHPfQA" %}
[Recipes](/recipes/before-we-start.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agentlabs.dev/getting-started/using-the-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
