> ## Documentation Index
> Fetch the complete documentation index at: https://developers.chatbrick.com/llms.txt
> Use this file to discover all available pages before exploring further.

# contact.connection.connected

> This event is triggered when a contact connects to a store or staff member.

<Warning>This event type is in the beta stage; specifications are subject to change at any time.</Warning>

## Event Body Fields

The request event body is a JSON object that contains the following fields:

<ResponseField name="type" type="string">
  `contact.connection.connected`
</ResponseField>

<ResponseField name="data" type="Object">
  The object containing the event data.

  <Expandable title="data" defaultOpen>
    <ResponseField name="contact" type="Contact Object">
      <Expandable title="contact">
        <ResponseField name="id" type="string" />

        <ResponseField name="name" type="string" />

        <ResponseField name="avatar" type="string">
          The URL of the contact's avatar.

          <Warning>We don't recommend embedding this image in any webpage because it's not designed for that purpose. If you need to display this image on a webpage, please download it when you receive the event and serve it from your own server to ensure it works as expected.</Warning>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="lineUsers" type="Array of LineUser Object">
      LINE users that belong to the contact. In most cases, there will be only one LINE user.

      <Expandable title="lineUser">
        <ResponseField name="id" type="string" />

        <ResponseField name="name" type="string">
          The name of the LINE user.

          This is the name of the LINE user, it can be different from the contact name in some cases.
        </ResponseField>

        <ResponseField name="lineUid" type="string">
          Learn more about it in [LINE User ID documentation](https://developers.line.biz/en/docs/messaging-api/getting-user-ids/).
        </ResponseField>

        <ResponseField name="lineProviderId" type="string">
          The LINE provider ID of the LINE user in. This value is sent as a string.
        </ResponseField>

        <ResponseField name="profilePictureUrl" type="string">
          The URL of the LINE user's profile picture.

          This URL is provided by LINE and it may already be expired when you receive the event.

          In most cases, you may want to use the avatar from the contact object instead.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="connectedStore" type="Store Object">
      In some rare cases, this field may be `null` if the contact is only connected to a staff member.

      <Expandable title="connectedStore">
        <ResponseField name="id" type="string">
          The permanent ID of the store in ChatBrick.
        </ResponseField>

        <ResponseField name="name" type="string" />

        <ResponseField name="logo" type="string">
          The URL of the store's logo.

          <Warning>
            We don't recommend embedding this image in any webpage because it's not designed for that purpose.

            If you need to display this image on a webpage, please download it when you receive the event and serve it from your own server to ensure it works as expected.
          </Warning>
        </ResponseField>

        <ResponseField name="externalId" type="string">
          The external ID is configured by the brand and is usually mapped to the brand's internal system.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="connectedStaff" type="Account Object or null">
      This field will be `null` if the contact is only connected to a store.

      <Expandable title="connectedStaff">
        <ResponseField name="id" type="string">
          The permanent ID of the account in ChatBrick.
        </ResponseField>

        <ResponseField name="storeId" type="string">
          ID of the account's primary store. The value will be `null` if the account has no primary store configured
          (e.g., a brand manager's account).
        </ResponseField>

        <ResponseField name="name" type="string">
          Name of the account.

          <Note>
            This is for internal communication purposes; the name should never be displayed in a public customer-facing interface.

            Use `displayName` for referring to the account in a public interface.
          </Note>
        </ResponseField>

        <ResponseField name="displayName" type="string">
          Name of the account for referring in a public interface.
        </ResponseField>

        <ResponseField name="employeeId" type="string">
          The employee ID is configured by the account and is typically mapped to the employee ID in the brand's HR
          system.
        </ResponseField>

        <ResponseField name="avatar" type="string">
          The URL of the account's profile picture (avatar).

          <Warning>
            We don't recommend embedding this image in any webpage because it's not designed for that purpose.

            If you need to display this image on a webpage, please download it when you receive the event and serve it from your own server to ensure it works as expected.
          </Warning>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="timestamps" type="Object">
      Timestamps in **ISO 8601** format.

      <Expandable title="timestamps">
        <ResponseField name="connectedAt" type="string">
          The timestamp of when the user performed the connect action.

          This will be the same as the `initConnectedAt` field when the contact is connected for the first time.
        </ResponseField>

        <ResponseField name="initConnectedAt" type="string">
          The timestamp when the contact is connected for the first time.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="timestampsMs" type="Object">
      Timestamps are represented in numerical format; the number represents **milliseconds** elapsed since the [epoch](https://en.wikipedia.org/wiki/Unix_time), which is defined as the midnight at the beginning of January 1, 1970, UTC.

      <Expandable title="timestampsMs">
        <ResponseField name="connectedAt" type="string">
          The timestamp of when the user performed the connect action.

          This will be the same as the `initConnectedAt` field when the contact is connected for the first time.
        </ResponseField>

        <ResponseField name="initConnectedAt" type="string">
          The timestamp when the contact is connected for the first time.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json Example: Store & Staff theme={null}
  {
    "type": "contact.connection.connected",
    "data": {
      "contact": {
        "id": "clrq5ca80000lb9c9dnxxfyid",
        "name": "康宜恩",
        "avatar": "https://uc.chatbrick.com/avatar/clrq5ca80000lb9c9dnxxfyid/avatar.jpeg"
      },
      "lineUsers": [
        {
          "id": "clxvsgpgi000001qgdxuka3vj",
          "name": "Mr. Kang",
          "lineUid": "U4d26836f2aadb5ad84cc8b5b729fc9a1",
          "lineProviderId": "1660894172",
          "profilePictureUrl": "https://profile.line-scdn.net/0m0450c48c7251b78e575b3a5bb3c4ea5a7e70d9d2d471"
        }
      ],
      "connectedStore": {
        "id": "clxvu9l6l000001p27bdm9ydk",
        "name": "台北101旗艦店",
        "logo": "https://imagedelivery.net/zdm_0V2jGvo4F5LeqaPJDQ/5178a7f8-661f-46d7-d852-0b72a2242100/public",
        "externalId": "10000"
      },
      "connectedStaff": {
        "id": "clxvu9uj3000001ob92yrb61o",
        "storeId": "clxvu9l6l000001p27bdm9ydk",
        "name": "何沛妮",
        "displayName": "小何 | 台北101旗艦店",
        "employeeId": "50001",
        "avatar": "https://imagedelivery.net/zdm_0V2jGvo4F5LeqaPJDQ/5178a7f8-661f-46d7-d852-0b72a2242100/public"
      },
      "timestamps": {
        "connectedAt": "2024-06-08T18:18:18.888Z",
        "initConnectedAt": "2024-06-08T18:18:18.888Z"
      },
      "timestampsMs": {
        "connectedAt": 1717870698888,
        "initConnectedAt": 1717870698888
      }
    }
  }
  ```

  ```json Example: Store only theme={null}
  {
    "type": "contact.connection.connected",
    "data": {
      "contact": {
        "id": "clrq5ca80000lb9c9dnxxfyid",
        "name": "康宜恩",
        "avatar": "https://uc.chatbrick.com/avatar/clrq5ca80000lb9c9dnxxfyid/avatar.jpeg"
      },
      "lineUsers": [
        {
          "id": "clxvsgpgi000001qgdxuka3vj",
          "name": "Mr. Kang",
          "lineUid": "U4d26836f2aadb5ad84cc8b5b729fc9a1",
          "lineProviderId": "1660894172",
          "profilePictureUrl": "https://profile.line-scdn.net/0m0450c48c7251b78e575b3a5bb3c4ea5a7e70d9d2d471"
        }
      ],
      "connectedStore": {
        "id": "clxvu9l6l000001p27bdm9ydk",
        "name": "台北101旗艦店",
        "logo": "https://imagedelivery.net/zdm_0V2jGvo4F5LeqaPJDQ/5178a7f8-661f-46d7-d852-0b72a2242100/public",
        "externalId": "10000"
      },
      "connectedStaff": null,
      "timestamps": {
        "connectedAt": "2024-06-08T18:18:18.888Z",
        "initConnectedAt": "2024-06-08T18:18:18.888Z"
      },
      "timestampsMs": {
        "connectedAt": 1717870698888,
        "initConnectedAt": 1717870698888
      }
    }
  }
  ```
</ResponseExample>
