# Message Conversion
URL: /docs/api-reference/external-store/message-conversion

Convert external message formats into assistant-ui's message and thread state for the external store runtime.

{/* AUTO-GENERATED PAGE by scripts/generate-api-reference.mts */}

{/* Do not edit manually. */}

{/* api-reference:start */}

{/* AUTO-GENERATED by scripts/generate-api-reference.mts */}

{/* Do not edit this block manually. */}

## API Reference \[#api-reference]

### getExternalStoreMessages \[#getexternalstoremessages]

```ts
const getExternalStoreMessages: <T>(input: { messages: readonly ThreadMessage[]; } | ThreadMessage | ThreadMessage["content"][number]) => T[];
```

### useExternalMessageConverter \[#useexternalmessageconverter]

<ParametersTable />

### unstable\_convertExternalMessages \[#unstable\_convertexternalmessages]

```ts
const unstable_convertExternalMessages: <T extends WeakKey>(messages: T[], callback: useExternalMessageConverter.Callback<T>, isRunning: boolean, metadata: useExternalMessageConverter.Metadata) => ThreadMessage[];
```

### unstable\_createMessageConverter \[#unstable\_createmessageconverter]

```ts
const unstable_createMessageConverter: <T extends object>(callback: useExternalMessageConverter.Callback<T>) => { useThreadMessages: ({ messages, isRunning, joinStrategy, metadata, }: { messages: T[]; isRunning: boolean; joinStrategy?: "concat-content" | "none" | undefined; metadata?: useExternalMessageConverter.Metadata; }) => ThreadMessage[]; toThreadMessages: (messages: T[], isRunning?: boolean, metadata?: useExternalMessageConverter.Metadata) => ThreadMessage[]; toOriginalMessages: (input: ThreadState | ThreadMessage | ThreadMessage["content"][number]) => unknown[]; toOriginalMessage: (input: ThreadState | ThreadMessage | ThreadMessage["content"][number]) => {}; useOriginalMessage: () => {}; useOriginalMessages: () => unknown[]; };
```

### bindExternalStoreMessage \[#bindexternalstoremessage]

Deprecated: This API is experimental and may change without notice.

Attach the original external store message(s) to a ThreadMessage or message part.
This is a no-op if the target already has a bound message.
Use `getExternalStoreMessages` to retrieve the bound messages later.

```ts
const bindExternalStoreMessage: <T>(target: object, message: T | T[]) => void;
```

{/* api-reference:end */}
