# Alert when there are new Auth0 users
workflow:
  id: new-auth0-users-monitor
  name: New Auth0 Users Monitor
  description: Tracks new Auth0 user signups and sends Slack notifications with detailed user information, maintaining state between runs.
  triggers:
    - type: interval
      value: 3600 # every hour
  steps:
    - name: get-auth0-users
      provider:
        type: auth0.logs
        config: "{{ providers.auth0 }}"
        with:
          log_type: ss
          previous_users: "{{ state.new-auth0-users.-1.alert_context.alert_steps_context.get-auth0-users.results.users }}" # state.alert-id.-1 for last run
  actions:
    - name: trigger-slack
      condition:
        - name: assert-condition
          type: assert
          assert: "{{ steps.get-auth0-users.results.new_users_count }} == 0" # if there are more than 0 new users, trigger the action
      provider:
        type: slack
        config: " {{ providers.slack-demo }} "
        with:
          blocks:
            - type: section
              text:
                type: plain_text
                text: There are new keep.len({{ steps.get-auth0-users.results.new_users }}) users!
                emoji: true
            - type: section
              text:
                type: plain_text
                text: |-
                  {{#steps.get-auth0-users.results.new_users}}
                  - {{user_name}}
                  {{/steps.get-auth0-users.results.new_users}}
                emoji: true