Search documentation of phoenix_kit

# PhoenixKit.Modules.CustomerService.TicketComment (phoenix_kit v1.7.87)

Copy Markdown View Source

Schema for ticket comments with internal notes support.

Supports nested comment threads (like PostComment) with self-referencing parent/child relationships. The `is_internal` flag distinguishes between public comments (visible to customer) and internal notes (staff only).

## Comment Types

- Public comments (`is_internal: false`) - Visible to customer and staff
- Internal notes (`is_internal: true`) - Visible only to support staff

## Fields

- `ticket_uuid` - Reference to the ticket
- `user_uuid` - Reference to the commenter
- `parent_uuid` - Reference to parent comment (nil for top-level)
- `content` - Comment text
- `is_internal` - True for internal notes, false for public comments
- `depth` - Nesting level (0=top, 1=reply, 2=reply-to-reply, etc.)

## Examples

    # Public comment from support
    %TicketComment{
      ticket_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      user_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      parent_uuid: nil,
      content: "Thank you for contacting us. We're looking into this.",
      is_internal: false,
      depth: 0
    }

    # Internal note (hidden from customer)
    %TicketComment{
      ticket_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      user_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      parent_uuid: nil,
      content: "Customer seems frustrated. Need to escalate to senior support.",
      is_internal: true,
      depth: 0
    }

    # Customer reply
    %TicketComment{
      ticket_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      user_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      parent_uuid: "018e3c4a-1234-5678-abcd-ef1234567890",
      content: "Thanks, I've tried that but it still doesn't work.",
      is_internal: false,
      depth: 1
    }

## Summary

### Types

t()

### Functions

changeset(comment, attrs)

Changeset for creating or updating a comment.

internal?(arg1)

Check if comment is an internal note.

public?(arg1)

Check if comment is public (visible to customer).

reply?(ticket_comment)

Check if comment is a reply (has parent).

top_level?(ticket_comment)

Check if comment is top-level (no parent).

## Types

# t()

    @type t() :: %PhoenixKit.Modules.CustomerService.TicketComment{
      __meta__: term(),
      attachments:
        [PhoenixKit.Modules.CustomerService.TicketAttachment.t()]
        | Ecto.Association.NotLoaded.t(),
      children: [t()] | Ecto.Association.NotLoaded.t(),
      content: String.t(),
      depth: integer(),
      inserted_at: DateTime.t() | nil,
      is_internal: boolean(),
      parent: t() | Ecto.Association.NotLoaded.t() | nil,
      parent_uuid: UUIDv7.t() | nil,
      ticket:
        PhoenixKit.Modules.CustomerService.Ticket.t()
        | Ecto.Association.NotLoaded.t(),
      ticket_uuid: UUIDv7.t(),
      updated_at: DateTime.t() | nil,
      user: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t(),
      user_uuid: UUIDv7.t() | nil,
      uuid: UUIDv7.t() | nil
    }

## Functions

# changeset(comment, attrs)

Changeset for creating or updating a comment.

## Required Fields

- `ticket_uuid` - Reference to ticket
- `user_uuid` - Reference to commenter
- `content` - Comment text

## Validation Rules

- Content must be 1-10000 characters
- is_internal defaults to false
- Depth automatically calculated from parent

# internal?(arg1)

Check if comment is an internal note.

# public?(arg1)

Check if comment is public (visible to customer).

# reply?(ticket_comment)

Check if comment is a reply (has parent).

# top_level?(ticket_comment)

Check if comment is top-level (no parent).