# Rule migration to Actions

**URL:** <https://community.auth0.com/t/rule-migration-to-actions/68876>\
**Category:** Get Help\
**Tags:** twitter, email\
**Created:** [August 31, 2021, 8:10pm UTC](https://community.auth0.com/t/rule-migration-to-actions/68876 "2021-08-31T20:10:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CueToDo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cuetodo/32/21184_2.png) [@CueToDo](https://community.auth0.com/u/CueToDo)\
**Post date:** [August 31, 2021, 8:10pm UTC](https://community.auth0.com/t/rule-migration-to-actions/68876/1 "2021-08-31T20:10:43Z")

</div>

I set up a rule some time ago to retrieve email from Twitter.

I’ve now been advised to migrate to Actions.

From what I’ve seen this is not a simple copy and paste and I can’t find an example.

Surely this is not up to each and everyone to develop their own action from scratch?

The only “scaffolding” is

```auto
exports.onExecutePostLogin = async (event, api) => {
};

```

This is the original rule

```auto
function (user, context, callback) {
  // additional request below is specific to Twitter
  if (context.connectionStrategy !== 'twitter') {
    return callback(null, user, context);
  }

  const oauth = require('oauth-sign');
  const uuid = require('uuid');

  const url = 'https://api.twitter.com/1.1/account/verify_credentials.json';
  const consumerKey = 'xxx';
  const consumerSecretKey = 'xxx;

  const twitterIdentity = _.find(user.identities, { connection: 'twitter' });
  const oauthToken = twitterIdentity.access_token;
  const oauthTokenSecret = twitterIdentity.access_token_secret;

  const timestamp = Date.now() / 1000;
  const nonce = uuid.v4().replace(/-/g, '');

  const params = {
    include_email: true,
    oauth_consumer_key: consumerKey,
    oauth_nonce: nonce,
    oauth_signature_method: 'HMAC-SHA1',
    oauth_timestamp: timestamp,
    oauth_token: oauthToken,
    oauth_version: '1.0'
  };

  params.oauth_signature = oauth.hmacsign('GET', url, params, consumerSecretKey, oauthTokenSecret);

  const auth = Object.keys(params).sort().map(function (k) {
    return k + '="' + oauth.rfc3986(params[k]) + '"';
  }).join(', ');

  request.get(url + '?include_email=true', {
    headers: {
      'Authorization': 'OAuth ' + auth
    },
    json: true
  }, (err, resp, body) => {
    if (resp.statusCode !== 200) {
      return callback(new Error('Error retrieving email from twitter: ' + body || err));
    }
    user.email = body.email;
    return callback(err, user, context);
  });
}

```

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 15, 2021, 6:12pm UTC](https://community.auth0.com/t/rule-migration-to-actions/68876/3 "2021-09-15T18:12:32Z")

</div>

Hi @CueToDo,

Welcome to the Auth0 Community!

I understand that you have a `Retrieve email from Twitter` Rule and have questions regarding migrating to Actions.

Currently, there are no equivalent templates in Actions, as you see with the Rules templates. However, we anticipate Action Templates to be available as no-code integrations for your development in the future.

For now, Auth0 will continue to offer support to Rules until the end of 2022, by which time, Rules will have reached its end of life, and you will need to migrate fully into Actions.

Because of this, I recommend waiting until the Action Templates become available and migrate over without any friction.

However, if you decide to develop a Custom Action based on similar logic, I recommend checking out our [Post-login Action Triggers](https://auth0.com/docs/actions/triggers/post-login) documentation.

Please let me know if you have any questions. I would be happy to clarify.

---

<div class="post-metadata">

**Author:** ![CueToDo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cuetodo/32/21184_2.png) [@CueToDo](https://community.auth0.com/u/CueToDo)\
**Post date:** [September 15, 2021, 8:30pm UTC](https://community.auth0.com/t/rule-migration-to-actions/68876/4 "2021-09-15T20:30:16Z")

</div>

Thanks Rueben, that’s great news, I’m happy to continue using the rule and wait for the Action Templates to become available.

Alex

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 15, 2021, 9:13pm UTC](https://community.auth0.com/t/rule-migration-to-actions/68876/5 "2021-09-15T21:13:06Z")

</div>

That’s great to hear @CueToDo!

Have a great rest of your day.

---

<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:** [September 30, 2021, 9:13pm UTC](https://community.auth0.com/t/rule-migration-to-actions/68876/6 "2021-09-30T21:13:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [December 22, 2021, 12:11pm UTC](https://community.auth0.com/t/rule-migration-to-actions/68876/7 "2021-12-22T12:11:04Z")

</div>

Hi @CueToDo  
I wanted to chime in and just mention that this will also help in transitioning from Rules to Actions [https://auth0.com/docs/actions/programming-model-changes](https://auth0.com/docs/actions/programming-model-changes)

Have a great holiday season.  
Regards

---

<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 22, 2021, 2:03pm UTC](https://community.auth0.com/t/rule-migration-to-actions/68876/8 "2021-12-22T14:03:15Z")

</div>

Thanks a lot for sharing that Saqib!

---

<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:31pm UTC](https://community.auth0.com/t/rule-migration-to-actions/68876/9 "2022-01-21T17:31:42Z")

</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.
