> For the complete documentation index, see [llms.txt](https://docs.ohmyapp.io/main/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ohmyapp.io/main/guide/faq/logic/3.md).

# 3. 작성 글에 댓글이 달리면 푸시 알림을 발송하고 싶어요.

1. **관리자 웹 > 로직 설정 > '+' 버튼을 클릭해 새로운 로직을 생성해 주세요.**&#x20;
2. **아래와 같이 입력해 주세요.**&#x20;
   * If When : Data is created
   * Where : \_docTimeline
   * Then : Send Push Notifications

> \_docTimeline은 댓글, 좋아요, 데이터 변경 로그, 이미지 정보, 업로드 파일 정보 등의 부가적인 데이터들을 저장해요.&#x20;

3. **Condition > Data condition을 펼쳐, 아래의 이미지와 같이 입력해 주세요.**&#x20;

<div align="left"><figure><img src="/files/nvuu4OBy3LyaRxbcybZ7" alt="" width="375"><figcaption></figcaption></figure></div>

* Condition 1 : 데이터가 등록된 컬렉션이 커뮤니티일 때
* Condition 2 : 데이터의 종류가 댓글일 때&#x20;
* Condition 3 : 피드 작성자와 댓글 작성자가 같지 않을 때

4. **New data query 에서 댓글에 답글 등록 시에는 푸시 알림이 전송되지 않도록 설정할 수 있어요.**

* "flows"에 데이터를 찾기 위해 "[@query](/main/guide/develop_app/command-execute-function/create-logic/conditions/detailed-processing-conditions/query.md)" 이벤트를 드래그앤드롭으로 추가해 주세요.

<div align="left"><figure><img src="/files/ekMSnkVO6DwBRR6r9iqV" alt="" width="563"><figcaption></figcaption></figure></div>

1. @query"를 이용해 "\_docTimeline"의 데이터를 찾아요.&#x20;
2. "#collection"에 찾고 싶은 컬렉션 명인 "\_docTimeline"을 기록해요.&#x20;
3. "#find"에 부모글을 찾는 조건식을 기록해요. "\_id"가 부모글의 "\_id"인 "newDocument.documentId"를 기록하여 "\_docTimeline"에 부모글을 찾아요.

* 찾은 데이터를 보관하기 위해 "flows"에 "[@setValue](/main/guide/develop_app/command-execute-function/create-logic/conditions/detailed-processing-conditions/setvalue.md)" 이벤트를 드래그앤드롭으로 추가해 주세요.&#x20;

<div align="left"><figure><img src="/files/LgLb5bJxQvKXkYaUushz" alt="" width="563"><figcaption></figcaption></figure></div>

1. "@setValue"를 통해 찾은 데이터의 첫 번째 항목을 보관해요.&#x20;
2. "@query"를 이용해 데이터를 가져오면 "tmpDocument.findDocument"에 조건에 맞는 모든 데이터들이 List 형식으로 보관돼요.&#x20;
3. "@setValue" 내부 "Object"의 "key"인 "\_reply"를 이용해 tmpDocument에서 보관하고 싶은 위치를 기록해요.&#x20;
4. "key"의 내부 "Object"에서 "#first"를 이용하여 "tmpDocument.findDocument"에서 첫 번째 요소를 가져와요

* 보관하고 있는 데이터를 확인하기 위해 "[@if](/main/guide/develop_app/command-execute-function/create-logic/conditions/detailed-processing-conditions/if.md)" 이벤트를 드래그앤드롭으로 추가해 주세요.
  * "#condition"에 "#isEmpty"조건을 드래그앤드롭으로 추가해 주세요.
    * "#condition"에서 특정 조건을 명시해요.
    * "#isEmpty"를 이용해 "tmpDocument.reply"가 빈 배열인지 확인해요.

<div align="left"><figure><img src="/files/PgbWFKSYuDdDwyouI9aj" alt="" width="563"><figcaption></figcaption></figure></div>

* "#ifFalse" 에 "@returnException" 이벤트를 드래그앤드롭으로 추가해 주세요.

<div align="left"><figure><img src="/files/L6f9RyRFYs51AbyCKMht" alt="" width="555"><figcaption></figcaption></figure></div>

1. "ifFalse"를 이용해 "tmpDocument.reply"가 빈 배열이 아닐 시 사용할 로직을 정의해요.

2. "@returnException"을 이용해 로직을 종료시켜요.

3. "message"를 이용해 어떤 예외인지 명시해요.

4. "code"는 강제 되지 않아요. "code" 값에 1이 들어갈 경우 정상 작동 되므로 1이 아닌 숫자를 입력해 주세요.&#x20;

5. **Then 아래, To do에서 푸시 알림에 대한 정보를 작성할 수 있어요.**

<div align="left"><figure><img src="/files/IfmiCQxt3RKhBm3a8lKC" alt="" width="375"><figcaption></figcaption></figure></div>

* "Subject"에 전송할 메세지의 제목을 작성해 주세요.
* "Content"에 전송할 메세지의 내용을 작성해 주세요.
  * "#{nickname}"을 작성해서 댓글 작성자의 닉네임을 변수로 사용해 보세요.
  * "Set variables to use in contents"에서 메세지 내용에 사용할 변수를 설정하기 위해 위의 이미지와 같이 작성해 주세요.
* "Recipient"에 "댓글이 달린 커뮤니티 피드 작성자"에게 메세지를 전송하기 위해 위의 이미지와 같이 작성해 주세요.
* "Notifications Click Type"에 메세지 클릭 시 댓글이 달린 피드 상세 화면으로 이동하기 위해 "Read Screen"을 선택해 주세요.

6. Save 버튼 클릭 후, 작성 글에 댓글이 달리면 작성자에게 푸시 알림이 발송돼요.

> \#로직, #로직 설정, #로직 설정하는 방법, #댓글이 달리면 앱 푸시 발송하기, #푸시 알림, #앱 알림 보내는 방법, #알림 설정하기, #댓글 알림 보내는 법

2024.01.11 Jinny
