# User Invitation flow - Need clarity

**URL:** <https://community.auth0.com/t/user-invitation-flow-need-clarity/85033>\
**Category:** Get Help\
**Tags:** forum\
**Created:** [June 13, 2022, 3:11pm UTC](https://community.auth0.com/t/user-invitation-flow-need-clarity/85033 "2022-06-13T15:11:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vidyarani.nethi](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vidyarani.nethi/32/37887_2.png) [@vidyarani.nethi](https://community.auth0.com/u/vidyarani.nethi)\
**Post date:** [June 13, 2022, 3:11pm UTC](https://community.auth0.com/t/user-invitation-flow-need-clarity/85033/1 "2022-06-13T15:11:54Z")

</div>

Hi,  
we are evaluating Auth0 user invitation flow for user signup. We have couple of questions that were not clear.  
Here is the flow we wanted to implement using User invitation

1. As a first step capture email along with country/region code
2. Send verification link, and user clicks on the link to verify email.
3. Show the password screen and user adds new passoword.
4. When user login with the username and passoword, the country code should be sent as part of the access token.

To achieve this using auth0, tried the following steps  
1.Disabled Welcome and verification email templates.  
2. Created a hook for post user registration as mentioned in [Sending Email Invitations For Application Signup](https://community.auth0.com/t/sending-email-invitations-for-application-signup/57326)  
3.created a user using the `api/v2/users` endpoint. User is created.  
But did not receive any email when user is created. What is missing here?

Questions:

1. Is the endpoint `api/v2/users` protected as it requires a bearer token or available to be accessed by any mobile clients?
2. Why is invitation mail not sent as mentioned in the above steps?

Detailed steps to achieve this flow is highly appreciated.  
Thanks

---

<div class="post-metadata">

**Author:** ![kpritam](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kpritam/32/37798_2.png) [@kpritam](https://community.auth0.com/u/kpritam)\
**Post date:** [June 19, 2022, 2:59pm UTC](https://community.auth0.com/t/user-invitation-flow-need-clarity/85033/2 "2022-06-19T14:59:05Z")

</div>

Hi @vidyarani.nethi

Actions are recommended over using rules + hooks. I tried above mentioned flow using Actions and I am getting password change email.

 ![rules](https://global.discourse-cdn.com/auth0/original/3X/9/c/9cda78424ff2abde0ee047a577db8062dd2b23d6.png)

**Steps that I followed:**

1. Create custom Post User Registration action, here I have called it `user-invitation`
2. Add below code to custom action

```auto
var AuthenticationClient = require('auth0').AuthenticationClient;

/**
* Handler that will be called during the execution of a PostUserRegistration flow.
*
* @param {Event} event - Details about the context and user that has registered.
*/
exports.onExecutePostUserRegistration = async (event) => {
  var authClient = new AuthenticationClient({
    domain: 'YOUR_DOMAIN',
    clientId: 'YOUR_CLIENT_ID',
  });

  var userAndConnection = {
    email: event.user.email,
    connection: 'Username-Password-Authentication',
    connection_id: event.connection.id,
  };

  authClient.requestChangePasswordEmail(userAndConnection, function(err){
    console.error(err)
  });
};

```

1. Drag and drop this newly created action between `Start` and `Complete` as shown below  
 ![post registration action](https://global.discourse-cdn.com/auth0/original/3X/c/1/c1c12381558743adce36437a3a052f2090ccb1f0.png)

---

<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:** [November 14, 2024, 12:58am UTC](https://community.auth0.com/t/user-invitation-flow-need-clarity/85033/3 "2024-11-14T00:58:25Z")

</div>

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