# ChatMessage Type documentation

## TypeScript declaration

### [ChatMessage](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L141-L146>)

**Kind:** type alias

```
import type { ChatMessage } from '@siemens/element-ng/chat-messages';
```

Chat message type union of all supported message types in the AI chat container.

See: [UserChatMessage](<index.html#t:UserChatMessage>) for user messages

See: [AiChatMessage](<index.html#t:AiChatMessage>) for AI messages

See: [ActivityChatMessage](<index.html#t:ActivityChatMessage>) for individual activities

See: [ActivityTraceChatMessage](<index.html#t:ActivityTraceChatMessage>) for grouped activities

See: [TemplateChatMessage](<index.html#t:TemplateChatMessage>) for template-based messages

See: [BaseChatMessage](<index.html#t:BaseChatMessage>) for the base chat message interface

See: [SiAiChatComponent](<../../components/SiAiChatComponent/index.html#SiAiChatComponent>) for the AI chat container where this is used

```
type ChatMessage = | UserChatMessage
  | AiChatMessage
  | ActivityChatMessage
  | ActivityTraceChatMessage
  | TemplateChatMessage
```

### Types Documentation

### [ActivityChatMessage](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L68-L94>)

**Kind:** interface

```
import type { ActivityChatMessage } from '@siemens/element-ng/chat-messages';
```

Progress or intermediate activity shown between chat messages.

```
interface ActivityChatMessage
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [autoExpand](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L89-L89>) (optional) | `boolean` | Overrides automatic expansion for this activity. |
| [autoExpandInputs](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L91-L91>) (optional) | `boolean \| string[]` | Overrides automatic input expansion. Record keys can be selected individually. |
| [autoExpandOutputs](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L93-L93>) (optional) | `boolean` | Overrides automatic output expansion. |
| [content](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L81-L81>) (optional) | `string \| Signal<string>` | Reasoning content rendered directly in the activity. |
| [icon](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L85-L85>) (optional) | `string \| false` | Alternative icon. Set to false to show the generic activity marker. |
| [input](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L73-L73>) (optional) | `string \| string[] \| Record<string, string>` | Activity inputs. Record entries are rendered as individual message parts. |
| [inputArgumentsLabel](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L75-L75>) (optional) | `TranslatableString` | Label for the input arguments section. |
| [loading](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L83-L83>) (optional) | `boolean \| Signal<boolean>` | Whether the activity is still running. |
| [messages](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L87-L87>) (optional) | `ActivityChatMessage[]` | Nested activities. |
| [name](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L71-L71>) (optional) | `TranslatableString` | Activity name. Defaults to the reasoning label for content-only activities. |
| [output](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L77-L77>) (optional) | `string` | Output from the activity. |
| [outputLabel](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L79-L79>) (optional) | `TranslatableString` | Label for the output section. |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L69-L69>) | `"activity"` |  |

### [ActivityTraceChatMessage](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L100-L108>)

**Kind:** interface

```
import type { ActivityTraceChatMessage } from '@siemens/element-ng/chat-messages';
```

Related activities grouped under a shared collapsible heading. The latest trace stays expanded until a user message follows it.

```
interface ActivityTraceChatMessage
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [autoExpand](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L107-L107>) (optional) | `boolean` | Overrides automatic expansion for this trace. |
| [messages](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L105-L105>) | `ActivityChatMessage[]` | Activities in execution order. |
| [name](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L103-L103>) | `TranslatableString` | Activity trace name. |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L101-L101>) | `"activity-trace"` |  |

### [AiChatMessage](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L58-L65>)

**Kind:** interface

```
import type { AiChatMessage } from '@siemens/element-ng/chat-messages';
```

AI chat message

See: [SiAiChatComponent](<../../components/SiAiChatComponent/index.html#SiAiChatComponent>) for the AI chat container where this is used

```
interface AiChatMessage extends BaseChatMessage
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [actions](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L64-L64>) (optional) | `MenuItemAction[]` | Actions available for this message |
| [content](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L62-L62>) | `string \| Signal<string>` | Message content - can be a string or a Signal\<string\>, empty string shows loading state, set signal back to string to end "streaming" state<br><br>Inherited from [BaseChatMessage](<index.html#t:BaseChatMessage>) |
| [loading](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L30-L30>) (optional, inherited) | `boolean \| Signal<boolean>` | Whether the message is currently loading/being generated - can be a boolean or Signal\<boolean\><br><br>Inherited from [BaseChatMessage](<index.html#t:BaseChatMessage>) |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L60-L60>) | `"ai"` | Type of message<br><br>Inherited from [BaseChatMessage](<index.html#t:BaseChatMessage>) |

### [TemplateChatMessage](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L118-L126>)

**Kind:** interface

```
import type { TemplateChatMessage } from '@siemens/element-ng/chat-messages';
```

Render custom chat message via template, consider using [SiChatMessageComponent](<../../components/SiChatMessageComponent/index.html#SiChatMessageComponent>) inside the template for consistent styling

See: [SiAiChatComponent](<../../components/SiAiChatComponent/index.html#SiAiChatComponent>) for the AI chat container where this is used

See: [SiChatMessageComponent](<../../components/SiChatMessageComponent/index.html#SiChatMessageComponent>) for the chat message wrapper component which can be used inside the template

```
interface TemplateChatMessage
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [template](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L122-L122>) | `TemplateRef<any>` | Template to render the message |
| [templateContext](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L125-L125>) (optional) | `any` | Context data to pass to the template |

### [UserChatMessage](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L40-L49>)

**Kind:** interface

```
import type { UserChatMessage } from '@siemens/element-ng/chat-messages';
```

User chat message for AI chats

See: [SiAiChatComponent](<../../components/SiAiChatComponent/index.html#SiAiChatComponent>) for the AI chat container where this is used

```
interface UserChatMessage extends BaseChatMessage
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [actions](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L48-L48>) (optional) | `MenuItemAction[]` | Actions available for this message |
| [attachments](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L46-L46>) (optional) | `Attachment[]` | Attachments (for user messages) |
| [content](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L44-L44>) | `string` | Message content, should be a string, empty string shows loading state<br><br>Inherited from [BaseChatMessage](<index.html#t:BaseChatMessage>) |
| [loading](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L30-L30>) (optional, inherited) | `boolean \| Signal<boolean>` | Whether the message is currently loading/being generated - can be a boolean or Signal\<boolean\><br><br>Inherited from [BaseChatMessage](<index.html#t:BaseChatMessage>) |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L42-L42>) | `"user"` | Type of message<br><br>Inherited from [BaseChatMessage](<index.html#t:BaseChatMessage>) |

### [Attachment](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/si-attachment-list.component.ts#L20-L25>)

**Kind:** interface

```
import type { Attachment } from '@siemens/element-ng/chat-messages';
```

Attachment item interface for file attachments in chat messages, used by [SiAttachmentListComponent](<../../components/SiAttachmentListComponent/index.html#SiAttachmentListComponent>) and inside [SiUserMessageComponent](<../../components/SiUserMessageComponent/index.html#SiUserMessageComponent>) as well as [SiChatInputComponent](<../../components/SiChatInputComponent/index.html#SiChatInputComponent>).

See: [SiAttachmentListComponent](<../../components/SiAttachmentListComponent/index.html#SiAttachmentListComponent>) for the attachment list component

See: [SiUserMessageComponent](<../../components/SiUserMessageComponent/index.html#SiUserMessageComponent>) for the user message

See: [SiChatInputComponent](<../../components/SiChatInputComponent/index.html#SiChatInputComponent>) for the chat input component

```
interface Attachment
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [name](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/si-attachment-list.component.ts#L22-L22>) | `string` | File name |
| [previewTemplate](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/si-attachment-list.component.ts#L24-L24>) (optional) | `TemplateRef<any> \| (() => TemplateRef<any>)` | Optionally show a preview of the attachment by providing a template that is shown in a modal when clicked (optional) |

### [MenuItemAction](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L34-L41>)

**Kind:** interface

```
import type { MenuItemAction } from '@siemens/element-ng/menu';
```

```
interface MenuItemAction extends MenuItemBase
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [action](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L40-L40>) | `string \| ((actionParam: any, source: MenuItemAction) => void)` | Action that called when the item is triggered. A function will be called, a string will be dispatched to the [SiMenuActionService](<../SiMenuActionService/index.html#t:SiMenuActionService>). |
| [badge](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L21-L21>) (optional, inherited) | `string \| number` | Badge that is rendered after the label.<br><br>Inherited from [MenuItemBase](<index.html#t:MenuItemBase>) |
| [badgeColor](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L23-L23>) (optional, inherited) | `string` | Color of the badge (not iconBadge).<br><br>Inherited from [MenuItemBase](<index.html#t:MenuItemBase>) |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L25-L25>) (optional, inherited) | `boolean` | Whether the menu item id disabled.<br><br>Inherited from [MenuItemBase](<index.html#t:MenuItemBase>) |
| [icon](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L14-L14>) (optional, inherited) | `string` | Optional icon that will be rendered before the label.<br><br>Inherited from [MenuItemBase](<index.html#t:MenuItemBase>) |
| [iconBadge](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L19-L19>) (optional, inherited) | `string \| number \| boolean` | Badge (always red) that is attached to the icon. If value===true, an empty red dot will be rendered.<br><br>Inherited from [MenuItemBase](<index.html#t:MenuItemBase>) |
| [id](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L10-L10>) (optional, inherited) | `string` | ID that will be attached to the DOM node.<br><br>Inherited from [MenuItemBase](<index.html#t:MenuItemBase>) |
| [label](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L12-L12>) (inherited) | `TranslatableString` | Label that is shown to the user.<br><br>Inherited from [MenuItemBase](<index.html#t:MenuItemBase>) |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L35-L35>) | `"action"` |  |

### [BaseChatMessage](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L24-L31>)

**Kind:** interface

```
import type { BaseChatMessage } from '@siemens/element-ng/chat-messages';
```

Base interface for all chat messages. Messages can be rendered either with content or with a custom template for advanced styling and functionality.

See: [ChatMessage](<index.html#t:ChatMessage>) for the chat message type union

See: [UserChatMessage](<index.html#t:UserChatMessage>) for user messages

See: [AiChatMessage](<index.html#t:AiChatMessage>) for AI messages

See: [TemplateChatMessage](<index.html#t:TemplateChatMessage>) for template-based messages

```
interface BaseChatMessage
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [content](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L28-L28>) (optional) | `string \| Signal<string>` | Message content - can be a string or a Signal\<string\>, empty string shows loading state |
| [loading](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L30-L30>) (optional) | `boolean \| Signal<boolean>` | Whether the message is currently loading/being generated - can be a boolean or Signal\<boolean\> |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/chat-messages/chat-message.model.ts#L26-L26>) | `"user" \| "ai"` | Type of message |

### [TranslatableString](<https://github.com/siemens/element/blob/main/projects/element-translate-ng/translate-types/global.types.ts#L18-L18>)

**Kind:** type alias

```
import type { TranslatableString } from '@siemens/element-translate-ng/translate-types';
```

Represents a translatable string. This can either be a translation key, e.g. `ACTIONS.EDIT` that will be automatically translated when displayed on the UI or a pre-translated string, e.g. `Edit`. Equivalent to a normal string in usage and functionality.

```
type TranslatableString = string & Translatable
```

### [MenuItemBase](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L8-L26>)

**Kind:** interface

```
import type { MenuItemBase } from '@siemens/element-ng/menu';
```

```
interface MenuItemBase
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [badge](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L21-L21>) (optional) | `string \| number` | Badge that is rendered after the label. |
| [badgeColor](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L23-L23>) (optional) | `string` | Color of the badge (not iconBadge). |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L25-L25>) (optional) | `boolean` | Whether the menu item id disabled. |
| [icon](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L14-L14>) (optional) | `string` | Optional icon that will be rendered before the label. |
| [iconBadge](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L19-L19>) (optional) | `string \| number \| boolean` | Badge (always red) that is attached to the icon. If value===true, an empty red dot will be rendered. |
| [id](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L10-L10>) (optional) | `string` | ID that will be attached to the DOM node. |
| [label](<https://github.com/siemens/element/blob/main/projects/element-ng/menu/si-menu-model.ts#L12-L12>) | `TranslatableString` | Label that is shown to the user. |
