---
docId: doc_6253f5f66e8f4248870fdd8978b3c6b0
title: Talk to your agent
description: "Send messages to your agent from an application and read the complete conversation."
---

<script>
  import { Steps, Ways } from '$lib/components';
</script>

# Talk to your agent

<span id="what-youll-build"></span>

Add an agent to a screen in your product. Your interface sends the message to your backend, which uses the Chat API to get the reply.

Use `conversationId` to continue the thread and read its history. To send and receive WhatsApp messages or email from your system, follow [Use channels through the API](/guides/messaging-api).

## Before you start

You need a [published agent](/guides/create-an-agent) with its id in `AGENT_ID` and your Platica API key in the backend. Keep the key on the server.

In the platform: [Start a chat](/help/chat/new-chat).

<Steps>
<Steps.Step>

**Send the first message**

Specify the agent, the message and the person sending it. The same call returns the agent's reply. ([Send a message to the agent](/api-reference/chat/send))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/chat \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "'$AGENT_ID'",
    "message": "Which plan fits a team of 25 people?",
    "client": { "id": "customer_123", "name": "Ana" }
  }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
import { Platic } from "platic-sdk";

const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! });

const turn = await platic.chat.send({
  agentId: process.env.AGENT_ID!,
  message: "Which plan fits a team of 25 people?",
  client: { id: "customer_123", name: "Ana" },
});

for (const reply of turn.messages) console.log(reply.content);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Ask the Sales agent which plan fits a team of 25 people.

</Ways.Say>

Tool: [`send_chat_message`](/mcp/tools#send_chat_message).

</Ways.Way>
</Ways>

The agent's reply is in `messages`. Save `conversationId` in `CONVERSATION_ID` to continue the thread and `id` in `CHAT_ID` to read its history.

Identify the person in `client` using the id from your system. Keep that id in future calls. If you omit `client`, the chat belongs to the key's owner.

</Steps.Step>
<Steps.Step>

**Follow the conversation**

Include `conversationId` to continue the thread. If you omit it, another thread is created.

To retain information about the person across different threads, enable [memory](/help/agents/memory) and use the same `client.id`.

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/chat \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "conversationId": "'$CONVERSATION_ID'",
    "message": "We also need WhatsApp."
  }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const next = await platic.chat.send({
  conversationId: turn.conversationId,
  message: "We also need WhatsApp.",
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Tell it we also need WhatsApp.

</Ways.Say>

Tool: [`send_chat_message`](/mcp/tools#send_chat_message) with the same conversation.

</Ways.Way>
</Ways>

The call waits for the agent to finish, including its tools. If you lose the response, read the conversation before resending the message: repeating it can generate another reply.

</Steps.Step>
<Steps.Step>

**Read the history**

It returns the full conversation, with the person's messages and the agent's in order. ([Get a chat](/api-reference/chat/get))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/chat/$CHAT_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const chat = await platic.chat.get(turn.id);

for (const message of chat.messages) console.log(message.role, message.content);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Show me the full conversation with the Sales agent.

</Ways.Say>

Tool: [`get_chat`](/mcp/tools#get_chat). To find an earlier conversation it uses [`list_chats`](/mcp/tools#list_chats).

</Ways.Way>
</Ways>

In each message, `role` says who spoke: `user` is the person and `assistant` is the agent.

</Steps.Step>
</Steps>

## Check it worked

Read the reply in `messages` and check that the history keeps the person's and agent's messages in order. Your team can also read or handle the conversation from the Platica inbox.

## Next steps

- [Put it on a channel](/guides/connect-a-channel) so it answers Messenger or Instagram.
- [Email by API](/api-reference/channels/email): write and reply to emails from a connected mailbox.
- [Embed the web chat](/guides/web-chat) to show Platica's chat inside your screen.
- [Send a message to the agent](/api-reference/chat/send): attachments, instructions for a single message and scheduled messages.
- [List chats](/api-reference/chat/list): the conversations of a contact or an agent.
- [Conversations](/api-reference/conversations): pause the agent, assign, tag, finish or archive what your agent handled.
