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

# 트랜잭션 메시지

> OneSignal의 API를 사용하여 푸시, 이메일 또는 SMS를 통해 개인화된 데이터로 OTP, 청구 업데이트 및 알림과 같은 트랜잭션 메시지를 보내는 방법을 알아보세요.

개인이나 소규모 그룹에게 시의적절하고 개인화된 메시지를 보내는 것은 강력한 고객 경험을 제공하고 참여를 유지하는 데 매우 중요합니다. 일회용 비밀번호(OTP), 청구 업데이트 또는 활동 확인과 같은 트랜잭션 메시지를 사용하면 서버에서 의미 있는 실시간 업데이트를 공유할 수 있습니다.

이 가이드는 사용자 지정 데이터 및 사용자 식별자를 사용하여 OneSignal의 API로 트랜잭션 메시지(푸시, 이메일 또는 SMS)를 보내는 방법을 설명합니다.

***

## 일반적인 사용 사례

다음을 위해 트랜잭션 메시지를 사용하세요:

* 로그인 및 확인 코드(OTP) 전송
* 주문, 영수증 또는 구독 변경 확인
* 청구 상태 또는 갱신 알림 전달
* 약속 또는 마감일에 대해 사용자에게 알림
* 주요 작업 확인(예: 가입 또는 구매)

***

## 요구사항

트랜잭션 메시지를 보내기 전에 다음 가이드를 검토하는 것이 좋습니다:

* OneSignal [사용자](./users), [구독](./subscriptions) 및 [별칭](./aliases)을 이해하세요.
* [OneSignal과 통신하도록 데이터베이스, DMP 또는 CRM을 설정](./database-dmp-crm-integration)하거나 [통합](./integrations) 중 하나를 사용하세요.
* 메시지를 개인화하기 위해 [템플릿](./templates)을 만드세요.
* 메시지를 개인화하기 위해 [Liquid 구문](./using-liquid-syntax)을 사용하세요.

***

## 사용자 식별

개별 사용자를 타겟팅하려면 OneSignal 내에서 사용자를 식별해야 합니다. 권장되는 접근 방식은 데이터베이스 또는 CRM에서 사용되는 사용자 식별자에 매핑되어야 하는 **외부 ID**를 설정하는 것입니다.

OneSignal은 **사용자당 최대 20개의 별칭**도 지원하므로 시스템 전체에서 여러 식별자(예: `other_user_id`, `facebook_id` 등)를 연결할 수 있습니다. 이메일 및 SMS의 경우 각각 이메일 주소 또는 전화번호를 사용하여 직접 메시지를 보낼 수도 있습니다.

***

## 사용자 타겟팅

[메시지 생성 API](/reference/create-message)를 사용하여 별칭, 이메일 주소, 전화번호 또는 구독 ID를 통해 사용자를 타겟팅하여 푸시, 이메일 및 SMS 채널에서 트랜잭션 메시지를 보냅니다.

### 별칭으로 전송(권장)

권장되는 `external_id` 또는 다른 별칭을 타겟팅하려면 `include_aliases`를 다음과 같이 사용하세요:

<CodeGroup>
  ```json external_id theme={null}
  {
    "app_id": "YOUR_APP_ID",
    "include_aliases": {"external_id": ["userA", "userB"]},
    "contents": {"en": "English Message"},
    "target_channel": "push"
  }
  ```

  ```json custom_alias theme={null}
  {
    "app_id": "YOUR_APP_ID",
    "include_aliases": { "alias_label": ["alias_id_1", "alias_id_2"] },
    "contents": { "en": "English Message" },
    "target_channel": "email"
  }
  ```
</CodeGroup>

### 구독으로 전송

특정 구독으로 전송하려면 `include_subscription_ids` 속성을 사용할 수 있습니다. 사용자는 여러 구독을 가질 수 있으므로 이 옵션은 권장되지 않습니다.

```json theme={null}
{
  "app_id": "YOUR_APP_ID",
  "include_subscription_ids": ["1dd608f2-c6a1-11e3-851d-000c2940e62c"],
  "contents": { "en": "English Message" }
}
```

### 이메일 주소로 전송

사용자의 이메일 주소가 있는 경우 `include_email_tokens` 속성을 사용하여 이메일을 보낼 수 있습니다.

OneSignal 앱 내에 존재하지 않는 포함된 이메일은 자동으로 새 이메일 구독을 생성합니다.

```json theme={null}
{
  "app_id": "YOUR_APP_ID",
  "include_email_tokens": ["user1@email.com", "user2@email.com"],
  "email_subject": "Welcome to Cat Facts!",
  "email_body": "<html><head>Welcome to Cat Facts</head><body><h1>Welcome to Cat Facts</h1><h4>Learn more about everyone's favorite furry companions!</h4><hr/><p>Hi Nick,</p><p>Thanks for subscribing to Cat Facts! We can't wait to surprise you with funny details about your favorite animal.</p><h5>Today's Cat Fact (March 27)</h5><p>In tigers and tabbies, the middle of the tongue is covered in backward-pointing spines, used for breaking off and gripping meat.</p><a href='https://catfac.ts/welcome'>Show me more Cat Facts</a><hr/><p><small>(c) 2018 Cat Facts, inc</small></p><p><small><a href='[unsubscribe_url]'>Unsubscribe</a></small></p></body></html>"
}
```

### 전화번호로 전송

사용자의 전화번호가 있는 경우 `include_phone_numbers` 속성을 사용하여 SMS 및 MMS를 보낼 수 있습니다.

OneSignal 앱 내에 존재하지 않는 포함된 전화번호는 자동으로 새 SMS 구독을 생성합니다.

```json theme={null}
{
  "app_id": "YOUR_APP_ID",
  "include_phone_numbers": ["+15555555555"],
  "contents": { "en": "English Message" }
}
```

***

## 사용자 지정 데이터 추가

개인화된 콘텐츠의 경우 템플릿 및 Liquid 구문을 사용하여 사용자별 `custom_data`를 메시지에 전달합니다.

사용자 지정 데이터를 추가하는 단계:

1. 대시보드 또는 [템플릿 생성 API](/reference/create-template)를 통해 [템플릿](./templates)을 만듭니다.
2. 템플릿에 [Liquid 변수](./using-liquid-syntax)(예: `{{ message.custom_data.order_id }}`)를 추가합니다.
3. 메시지 생성 API 호출 내에서 `template_id` 및 `custom_data`를 참조합니다.

```json theme={null}
{
  "app_id": "YOUR_APP_ID",
  "include_aliases": { "external_id": ["userA"] },
  "template_id": "8458af75-4da2-4ecf-afb5-f242a8926cc3",
  "custom_data": { "order_id": 123, "currency": "USD", "amount": 25 }
}
```

### 예시: 일회용 비밀번호(OTP)

1. 별칭, 이메일 또는 전화번호를 사용하여 사용자를 식별합니다.
2. 확인 코드가 포함된 템플릿을 만듭니다:

```
귀하의 확인 코드는 {{ message.custom_data.verification_code }}입니다
```

3. 사용자가 액세스를 요청할 때 서버에서 `verification_code`를 생성합니다.
4. `verification_code` 값을 API 요청에 입력합니다.

```json theme={null}
{
  "app_id": "YOUR_APP_ID",
  "include_aliases": { "external_id": ["userA"] },
  "template_id": "8458af75-4da2-4ecf-afb5-f242a8926cc3",
  "custom_data": { "verification_code": "123456" }
}
```

**대안:** 템플릿 및 `custom_data`를 사용하지 않으려는 경우 문자열 연결을 사용하여 변수 값을 메시지에 직접 입력할 수 있습니다. 예를 들어:

```json theme={null}
{
  "app_id": "YOUR_APP_ID",
  "include_aliases": {"external_id": ["userA"]},
  "contents": {"en": "Your verification code is " + verification_code}
}
```

***

## 문제 해결

* `include_aliases`의 경우 별칭이 사용자에게 미리 등록되어 있어야 합니다.
* 이메일/SMS의 경우 올바른 형식인지 확인하세요.

***

## 추가 리소스

* [메시지 생성 가이드](/reference/create-message)
* [사용자](./users) 및 [별칭](./aliases)
* [템플릿](./templates) 및 [Liquid 구문](./using-liquid-syntax)
* [속도 제한](/reference/rate-limits)

***
