# Guide: Migrate your custom Rules to Auth0 Actions

**URL:** <https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915>\
**Category:** Get Help\
**Tags:** jwt, actions, rules, access-token, login\
**Created:** [September 1, 2021, 10:48am UTC](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915 "2021-09-01T10:48:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikolay](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nikolay/32/13374_2.png) [@nikolay](https://community.auth0.com/u/nikolay)\
**Post date:** [September 1, 2021, 10:48am UTC](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915/1 "2021-09-01T10:48:31Z")

</div>

Due to the future deprecation of Auth0 Rules, users are required to migrate their custom Rules to the latest Auth0 Actions.

This post will guide you through this migration process.

## Auth0 Rule to migrate

**Name:** Add user information to access token

**Script:**

```auto
function (user, context, callback) {
  // This rule adds the authenticated user's email address to the access token.

  var namespace = 'https://mydomain.com/';

  context.accessToken[namespace + 'email'] = user.email;
  context.accessToken[namespace + 'email_verified'] = user.email_verified;

  return callback(null, user, context);
}

```

## Create Auth0 custom Action

1. Go to Actions → Flows → Login  

2. Go to the “Custom” tab and click “Create Action”  

3. Give the action a name  

4. Here’s how the Action version of the old Auth0 Rule looks like:

5. You can click on the “Test” button before deploying  

6. After you’ve the deployed the Action, you want to drag it into the Login flow  

7. Make sure to click “Apply” in order to save the latest changes  

8. Now you can disable the old Rule, since the new Action that we created has already been deployed  

## Additional resources

You can take a look at the docs for more comprehensive code examples on the new Auth0 Actions:

- [Login Trigger](https://auth0.com/docs/actions/triggers/post-login)

---

<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:** [September 1, 2021, 11:50am UTC](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915/2 "2021-09-01T11:50:21Z")

</div>

Thanks for sharing it with the rest of community Nikolay!

---

<div class="post-metadata">

**Author:** ![janco1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/janco1/32/12805_2.png) [@janco1](https://community.auth0.com/u/janco1)\
**Post date:** [October 14, 2021, 8:00am UTC](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915/3 "2021-10-14T08:00:45Z")

</div>

I have a rule straight from the documentation [Change User Pictures](https://auth0.com/docs/users/change-user-picture)

```auto
function (user, context, callback) {
  if (user.user_metadata.picture)
    user.picture = user.user_metadata.picture;

  callback(null, user, context);
}

```

How do I migrate that?  
I suppose it is adding attributes to the identity token instead of access token

---

<div class="post-metadata">

**Author:** ![darin.laframboise](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/darin.laframboise/32/23709_2.png) [@darin.laframboise](https://community.auth0.com/u/darin.laframboise)\
**Post date:** [December 20, 2021, 6:11pm UTC](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915/4 "2021-12-20T18:11:09Z")

</div>

Thank you for sharing Nikolay! This is a great guide. Just one clarification, we have not formally announced the feature deprecation of Rules & Hooks yet. However, Actions is very much our flagship extensibility product and I highly encourage everyone who has used Rules & Hooks in the past to migrate to Actions where they can take advantage of a greatly improved developer experience.

---

<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:** [December 21, 2021, 10:11am UTC](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915/5 "2021-12-21T10:11:09Z")

</div>

Thanks for following up on that Darin!

---

<div class="post-metadata">

**Author:** ![josh.cunningham](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/josh.cunningham/32/16289_2.png) [@josh.cunningham](https://community.auth0.com/u/josh.cunningham)\
**Post date:** [January 21, 2022, 5:30pm UTC](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915/6 "2022-01-21T17:30:40Z")

</div>

We now have an official guide to migrating from Rules to Actions!

> **[Migrate from Rules to Actions](https://auth0.com/docs/customize/actions/migrate/migrate-from-rules-to-actions)**
>
> Learn how to migrate your existing Auth0 Rules code to Auth0 Actions code.

---

<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:** [February 3, 2022, 1:54pm UTC](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915/7 "2022-02-03T13:54:40Z")

</div>

Thanks Josh for following up on that thread!

---

<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:** [February 18, 2022, 1:55pm UTC](https://community.auth0.com/t/guide-migrate-your-custom-rules-to-auth0-actions/68915/8 "2022-02-18T13:55:06Z")

</div>

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