# \[부가서비스\] 액션봇 사용법

**URL:** <https://ask.selectfromuser.com/t/topic/155>\
**Category:** 자유게시판\
**Tags:** actionbot\
**Created:** [5월 3, 2024, 5:35오전 UTC](https://ask.selectfromuser.com/t/topic/155 "2024-05-03T05:35:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbkim](https://yyz2.discourse-cdn.com/flex032/user_avatar/ask.selectfromuser.com/hbkim/32/23_2.png) [@hbkim](https://ask.selectfromuser.com/u/hbkim)\
**Post date:** [5월 3, 2024, 5:35오전 UTC](https://ask.selectfromuser.com/t/topic/155/1 "2024-05-03T05:35:20Z")

</div>

셀렉트어드민의 [액션봇 부가서비스](https://intercom.help/selectfromuser/ko/articles/9070566-%EC%95%A1%EC%85%98%EB%B4%87)(유료)를 통해 웹훅과 함께 worflow를 실행할 수 있습니다.

해당 기능을 이용하기 위해서는 키(key) 발급이 필요합니다.

서비스내 채팅이나 [영업팀](mailto:sales@selectfromuser.com)에 문의주시면 안내드리겠습니다.

### 현재 지원하는 trigger

- browser push notification
- js
- slack message (준비중)
- send email (slack email로도 가능)
- http request
- query

### 예제: 이메일 발송

```yaml
webhooks:
  test-cron: # webhooks url key
    name: 스케쥴러 테스트
    botOptions:
      trigger: send email
      to: test-slack-aaaalxxxxxxxxxbsgrr77cee@myteamname.slack.com
      subject: "[셀렉트] 테스트 10분"
      title: 알림
      body: >
        테스트 test

```

### 예제: 외부 쇼핑몰 주문 수집

- 외부 API를 통해 주문을 수집
- 실패시 이메일 알림 보내기
- 성공시 데이터 처리 및 저장

```yaml
webhooks:
  get-orders:
    name: 주문수집_콜백
    botOptions:
      autoload: true
      trigger: cafe24 get orders
      startDate: -3
      endDate: 0
      else:
        trigger: send email
        to: testemail@domain.com
        subject: "테스트"
        title: 알림
        body: >
          테스트
      then:
        trigger: js
        script: |
          data.orders.map(e => e.order_id, JSON.stringify(e)])
        then:
          trigger: query
          resource: mysql.dev
          forEach: true
          keepParams: true
          sql: |
            INSERT INTO test_table (order_code, json)
            VALUES (?, ?)
            ON DUPLICATE KEY UPDATE json = VALUES(json);
          then: 
            trigger: js
            script: |
              {
                found: data.affectedRows?.length,
                added: data.affectedRows?.map(e => e.insertId).filter(e => e>0).length,
              }
            else:
              trigger: send email
              to: testemail@domain.com
              subject: "수집 실패"
              title: 알림
              body: >
                주문수집이 완료되지 않았습니다.

                원인: 어드민 테이블 오류

```

### 예제: 브라우저 푸시 메시지

```yaml
      trigger: browser push notification
      message: |
        [셀렉트] {{count}}건 주문수집완료: {{message}}

```

### 예제: 슬랙 메시지 (준비중)

```yaml
      trigger: slack message
      channelId: C06xxxxxPSA
      message: 결제완료
      requestSlackPermission: true

```
