> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# visibleMessages

> Reduce a conversation log to the turns a browser may redraw.

[chatgateway]: /docs/server-sdks/reference/typescript/agents/chat-gateway

[lastactivity]: /docs/server-sdks/reference/typescript/agents/chat-gateway/last-activity

[log]: /docs/server-sdks/reference/typescript/agents/ai-chat-client/log

A static method that returns the transcript a browser may redraw, and nothing else. The service's
log holds the substituted system prompt and the tool calls and results alongside the dialogue, so
relaying it would publish your prompt to anyone with a handle.

Only `user` and `assistant` messages with non-blank text are kept. Each is reduced to `role`,
`content` and, when the source message is dated, `timestamp` in epoch seconds, so a restored
transcript isn't shown as sent now. The gateway's `log` method uses this before it answers, and
[`lastActivity()`][lastactivity] reads the same log for the idle clock.

## Parameters

**`messages`** `readonly unknown[] | null | undefined` — required

Messages as [`log()`][log] returns them in `messages`.

---

## Returns

`Array<Record<string, unknown>>` -- the visible turns, in order.

## Examples

```typescript
import { AIChatClient, ChatGateway } from '@signalwire/sdk';

const client = new AIChatClient({ space: 'your-space' });

const log = await client.log('chat-8f21');
const transcript = ChatGateway.visibleMessages(log.messages);

for (const turn of transcript) {
  console.log(`${String(turn.role)}: ${String(turn.content)}`);
}
```