# Auth0 Action triggering more than once?

**URL:** <https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856>\
**Category:** Get Help\
**Created:** [October 6, 2021, 6:04am UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856 "2021-10-06T06:04:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![robinhuang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/robinhuang/32/12835_2.png) [@robinhuang](https://community.auth0.com/u/robinhuang)\
**Post date:** [October 6, 2021, 6:04am UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856/1 "2021-10-06T06:04:21Z")

</div>

I have an action in the Login Flow that sends a New User message every time someone signs up. My code filters out only users who have a login\_count of 1.

```auto

exports.onExecutePostLogin = async (event, api) => {
  // If user is logged in for the first time. 
  if (event.stats.logins_count === 1) {
    const slack = require('slack-notify')(event.secrets.SLACK_WEBHOOK_URL);
    
    const message = `New User: ${event.user.email} (${event.user.name || (event.user.given_name && event.user.family_name) || event.user.username || ""})`;
    const channel = '#new-users';

    slack.success({
    text: message,
    channel: channel
    });
}

```

However, my slack got a few identical messages. One at  
12:05AM PST,  
12:15 AM PST,  
10:46PM PST on 10/05/2021.

Is the action triggering more than once?

---

<div class="post-metadata">

**Author:** ![jeff0](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeff0/32/30027_2.png) [@jeff0](https://community.auth0.com/u/jeff0)\
**Post date:** [October 6, 2021, 8:19am UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856/2 "2021-10-06T08:19:03Z")

</div>

Hi @robinhuang

Thank you for contacting Auth0 Community!!!

You can implement [Post registration action](https://auth0.com/docs/actions/triggers/post-user-registration) for this purpose.

The current implementation you have is for post-login which will trigger every time the user logs in.

Hope it helps !!!

Thank you  
Jeff

---

<div class="post-metadata">

**Author:** ![robinhuang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/robinhuang/32/12835_2.png) [@robinhuang](https://community.auth0.com/u/robinhuang)\
**Post date:** [October 6, 2021, 4:45pm UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856/3 "2021-10-06T16:45:41Z")

</div>

Hi Jeff,

Thanks for the quick reply. My issue is, I want to notify signups through social logins too (fb, google). Post registration doesn’t trigger for these.

I feel like my implementation in the Login flow should work, given I filter by login\_count.

Do actions trigger more than once with the same event? Any other way to get notified for social sign ups?

---

<div class="post-metadata">

**Author:** ![jeff0](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeff0/32/30027_2.png) [@jeff0](https://community.auth0.com/u/jeff0)\
**Post date:** [October 7, 2021, 4:08am UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856/4 "2021-10-07T04:08:41Z")

</div>

Hi @robinhuang

I tested this myself and I figured post-login action also runs on _ **Successful silent authentication** _. So if you login and your app also trigger a Silent Authentication check then that will be cause the post login to run again hence that action is triggered twice. You can check Actions triggered as part of login flows in Monitoring → Logs and select the Success Login event to see details.

Let me know if that is the reason in your case.

Thanks  
Jeff

---

<div class="post-metadata">

**Author:** ![robinhuang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/robinhuang/32/12835_2.png) [@robinhuang](https://community.auth0.com/u/robinhuang)\
**Post date:** [October 7, 2021, 4:46am UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856/5 "2021-10-07T04:46:17Z")

</div>

Hi Jeff,

That makes sense. The logs show multiple “Success Login”, even thought the login\_count is 1. Is there way to discern that from the Login event in the Action?

Best,

Robin

---

<div class="post-metadata">

**Author:** ![jeff0](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeff0/32/30027_2.png) [@jeff0](https://community.auth0.com/u/jeff0)\
**Post date:** [October 7, 2021, 5:06am UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856/6 "2021-10-07T05:06:05Z")

</div>

Hi robin

You should be able to do this to detect silent auth.

if (event.request.query.prompt === ‘none’) {  
}

Thanks  
Jeff

---

<div class="post-metadata">

**Author:** ![robinhuang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/robinhuang/32/12835_2.png) [@robinhuang](https://community.auth0.com/u/robinhuang)\
**Post date:** [October 8, 2021, 2:21am UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856/7 "2021-10-08T02:21:32Z")

</div>

Thank you so much for your help!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [October 8, 2021, 7:28am UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856/8 "2021-10-08T07:28:05Z")

</div>

We are here for you!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 23, 2021, 7:28am UTC](https://community.auth0.com/t/auth0-action-triggering-more-than-once/70856/9 "2021-10-23T07:28:35Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
