Getting started
Truework Direct allows an employee to log into their payroll platform and share their income/employment data directly via Truework Credentials.
The Truework.js widget allows you to embed this employee-driven verification workflow directly in your user-facing application. If the employee cannot login to their payroll provider for any reason, you have the option to still verify any employee in the US with a fallback that leverages Truework Smart Outreach.
Now let’s show you how to get up and running with Truework Direct with Truework.js and Truework Credentials.
This tutorial uses code snippets from the Truework.js examples repository. The Truework.js examples repository contains fully functioning Credentials demo applications using various platforms that you can use to bootstrap your own deployment.
Tutorial
This tutorial will walk you through the following steps to get a basic Truework Direct integration set up:
This tutorial will use Truework’s sandbox environment. There are a few key differences between Truework’s sandbox and production environments:
- The sandbox environment does not support co-branding.
- Credentials verifications in the sandbox environment supports the use of special test SSNs to simulate different scenarios.
- Credentials verifications in the sandbox environment uses a sign-in screen which accepts any username/password combination.
Adding Truework.js to your site
Add the Truework.js script tag to your application’s HTML page(s) as shown below. On page load, Truework.js will be available on the global window.Truework
object.
Creating a Truework Direct session and initializing Truework.js
Truework.js must be initialized with a Truework Direct session token that you create on your backend service with the Truework API. This session token will associate the applicant-provided information with your Truework account for later retrieval and use. The process of requesting and retrieving a session token and initializing Truework.js with the token is shown in the diagram below:
Now let’s implement this process.
If you haven’t already created a sandbox API key, use Developer Settings to create a new sandbox API key. Your sandbox API key should begin with tw_sk_test_
.
On your backend, create an API endpoint that calls POST /orders/truework-direct
to initialize a Credentials session. The Session Create API generates a token which is returned to your front end client and is used to instantiate Truework.js
If you haven’t already created a sandbox publishable key, use Developer Settings to create a new sandbox publishable key. Your sandbox publishable key should begin with tw_pk_test_
.
The Truework.js widget will activate when the button is clicked and the user will be guided through the Credentials flow. Once the user successfully completes the Credentials flow, you will asynchronously receive updates on the Credentials session through webhooks and fetch the related report data when the data is ready.
Listening for updates with webhooks and retrieving report data
Truework uses webhooks to notify you when a Truework Direct session changes state and successfully completes:
- You’ll receive a
credentials_session.state.change
webhook when the session successfully completes and a verification report is created. - You’ll receive a
order.completed
webhook when all verifications associated with the order have been completed or canceled.
You can then use the webhook notification of a completed report to fetch the report data, as shown in the diagram below:
Now let’s implement this process.
Create a new sandbox webhook in Developer Settings, targeting the webhook endpoint you just created. Take note of the token associated with the new sandbox webhook and insert it where YOUR_WEBHOOK_TOKEN
is in the example code
Moving to production
To promote your sandbox application to production, take the following steps:
Additional features
Callbacks
Callbacks can be configured so that your frontend application can learn about events occurring inside the Credentials flow.
Tracking data can be attached to the request so that your system can associate the verification with the user.
Example of callbacks
Co-branding
Enterprise customers can use Truework Direct co-branding to customize the logo and theme color for each publishable key. Go to your Truework application -> Developer -> Truework.js keys and edit to customize.
Fallback methods
If the employee doesn’t remember their payroll credentials or is unable to login to their payroll account, Truework.js can be configured to kickstart a verification automatically via Smart Outreach.
The setting to toggle the fallback method on or off can be set when your production access is granted.