Getting Started

Sample Application

The ZeroCRM sample application at auth0/extend is a working example of integrating Auth0 Extend into a hypothetical CRM system. As different integration aspects are discussed in this guide, you will see references to specific locations in the source code that demonstrate implementation details.

ZeroCRM

To run the ZeroCRM application you will need the following configuration details:

  • {host_url}: The HTTPS URL for your Auth0 Extend instance.
  • {master_webtask_token}. This is the main webtask token you were provided with to manage your installation.
  • {webtask_container}. This is the main webtask container.

If you are an existing Auth0 Extend customer, you were provided these as part of the onboarding process. If you are new to Auth0 Extend and want to try it out for free, you can get these parameters from the Try Auth0 Extend page.

To install the application, run the following:

git clone https://github.com/auth0/extend.git
cd extend/samples/zerocrm
npm i
cat > .env <<EOF
MASTER_WEBTASK_TOKEN={master_webtask_token}
HOST_URL={host_url}
WEBTASK_CONTAINER={webtask_container}
ZEROCRM_TENANT={webtask_container}
EOF

Auth0 Extend has been designed to support code-based extensibility in multi-tenant systems. Normally the concept of a tenant is implied from the authentication context. For the sake of simplicity, the ZeroCRM sample application assumes the tenant name will be provided via an environment variable when you start the application. This can be provided by modifying the local .env file you create above and overriding ZEROCRM_TENANT with the tenant name.

ZEROCRM_TENANT=tenant1

NOTE if you are using the free trial of Auth0 Extend, your account is single-tenant and cannot be used with arbitrary tenant names. In this case, please leave the ZEROCRM_TENANT environment variable set to the default value.

Walkthrough

Here is a quick walkthrough of using ZeroCRM.

  • Run the app with the command: DEBUG=zerocrm npm start
  • Open your browser to http://localhost:3000. You’ll see a screen for creating leads.

  • Enter the name Customer and put the value 5000.
  • Click Create Lead and you’ll notice that a JSON result is returned showing the lead has been created.

  • Zero CRM uses Auth0 Extend to execute custom user actions on creation of the lead. The Settings screen is where you do this configuration.
  • Right click on the ‘Settings` link and open it in a new tab.

  • Click on the Edit button for On new lead. You will see the Extend Editor appear with the following code:
// This code will execute whenever a new lead is created.
// Use 1000+ Node.js modules here. 

module.exports = function(ctx, cb) {
  console.log('On new lead:', ctx.body);
  
  var lead = ctx.body;
  
  if (lead.value > 1000) {
    // Send e-mail to manager
    // ...
  }

  // lead.profile = getProfileFromFullContact(lead.email);
  lead.profile = {
    vip: true,
    comment: 'This was added by custom code'
  };
 
  // return the newly created lead
  cb(null, lead);
};

The code for the action was created on “Edit” for illustration, in a real system you would likely have a different default template. This code first writes out to the console when a new lead is created. It then checks to see if the lead value is greater than $1000 and has a placeholder for sending an email. Finally, it tacks on additional profile information to the returned lead.

Before continuing, click the “Logs” button second from the right in the upper toolbar.



This will allow you to view real time logs as the action is invoked.

  • Go back to the “Leads” tab and hit Create New Lead again.
  • This time after the lead is created, you will see the profile information which has been appended.

  • Go back to the “Settings” tab.
  • You’ll see that the log shows that your new lead was created.



This is just the beginning of what is possible with Auth0 Extend! You’ll learn much more throughout the rest of the Extend User’s Guide.