Skip to content

Blog / Architecture and integration

Callable Lookup: Employee Directory

Here we explore the "callable lookup" design concept through the lens of an employee directory, where you can search for an employee with a variety of system identifiers.

Callable lookups are a useful design pattern when it comes to running a large scale automation practice. The idea is simple, you maintain a “lookup table” with the data storage connector, or the CSV editor, and enable the ability to search the table using a fire and wait for response callable workflow.

A Marketing Ops use case may be to leverage one for their email validation process, by having a lookup table for domains of common disposable email providers.

Here at Tray, one of our favorite lookups is our employee directory callable. Each employee has a directory entry with basic information like their name and email, as well as user IDs for the systems we commonly build automations around, like Salesforce and Slack.

I took a look at our Insights Hub to get a sense of how often we use this process every month and learned it was called almost 13,000 times by 81 different workflows. Even though a number of the 81 were in low use, I was still pretty surprised to see that many processes had called it!

Tray Insights Hub showing the Employee Directory callable workflow with 75.8K task runs and 12.7K successful runs over 28 days

Employee Directory Callable - Stats

Why use callable lookups?

There’s a few reasons why you might want to use a lookup like this workflow:

  1. Reducing rate limiting issues: Storing data locally means you don’t need to make any additional API calls to external systems. We actually built this initially to reduce the number of Slack API calls we were making as we were getting errors due to rate limits.
  2. Faster and more reliable processes: Less external calls, means much faster processes and less susceptibility to intermittent issues with external APIs.
  3. Better cross-system process automation: It’s much easier to string processes together across multiple systems when you have a person’s systems IDs easily at hand.
  4. It’s Fun: We have a cool feature with our directory where we allow Salesforce users to store a custom GIF link on their user profile. We store that on their directory entry and use it to send a congrats to them, like when they close a deal:

Slack message from a Tray.io app sending a congratulatory Captain Insano GIF to a teammate named Bobby

Employee Directory Callable: Slack win

The directory callable allows you to search for an employee using any of the properties in their entry. For example, you could search for them using their email:

Call Workflow step configured to Fire and wait for response, with Search Key set to Email and Search Value niels@tray.io

Employee Directory Callable: Lookup by email input schema

Or any other system ID in the directory, like their Slack ID:

Search Key dropdown open showing options Email, Salesforce ID, Slack ID, Full Name, First Name, Last Name with Slack ID selected

Employee Directory Callable: Search keys dropdown

Here’s what an example entry in the directory might look like:

{
  "email": "merlin@tray.io",
  "first_name": "Merlin",
  "last_name": "Manroe",
  "salesforce_id": "3jd0",
  "slack_id": "1we",
  "outreach_id": 123,
  "chili_piper_id": "123"
}

The entries are stored in a lookup table using the data storage connector. The directory callable has is a pretty simple workflow design which first grabs the directory from the “account” scope of data storage, then uses the search key and search value from the trigger inputs to form a filter object:

Vertical workflow diagram with six steps: Search directory by key trigger, Get directory, Setup search filter, Search directory, Count results, Send result

Employee Directory Callable: Callable example steps

Tray workflow logs panel showing the Setup search filter script input variables and the resulting JSON output for niels@tray.io

Employee Directory Callable: Logs

The filter object is passed to a “filter” list helper step, where the list you’re filtering is your lookup table (aka “employee directory”):

Search directory step configured as a Filter list-helpers operation with a Filter object bound to the previous script result

Employee Directory Callable: example filter step

A count of the number of matching results is done using the results from the filter step and it’s all sent back to the workflow that called:

Send result step using a callable-workflow-response with a Response schema returning Count and Records mapped from the list-helpers steps

Employee Directory Callable: callable response

Here’s a sample response:

"response": {
		"count": 1,
		"records": [
			{
				"full_name": "Merline Manroe",
				"outreach_id": 42,
				"chili_id": "5d4b5314ofpe2000133lds3a",
				"slack_id": "UKUPW8UQM",
				"last_name": "Manroe",
				"first_name": "Merlin",
				"email": "merlin@tray.io",
				"salesforce_id": "0054H0000057ggZQAQ"
			}
		]
	}
}

How the directory is created

There’s a dedicated workflow with a simple design pattern to follow that’s used to build the directory:

  1. Start with an official list of employees that includes their email
  2. Search each system you wish to associate to their directory entry for their user and email
  3. Join the results from each system to the official list using their email
  4. Store the joined results in data storage at the “account” scope

We do the join with a version of our list helper callable utility [List Helper Callables] Left join array of objects using 1 or more shared properties. This callable takes a left table and joins any matching entries from a right table where the right table entry shares a key with the left table entry:

Workflow segment showing three sequential call-workflow steps: Get Slack users, Get Salesforce users, Join in SFDC

Employee Directory Callable: join steps

Join in SFDC step configured with Left Table from call-workflow-1 users and Right Table from call-workflow-2 users, plus Joining Properties section

Employee Directory Callable: join inputs

Joining Properties detail with Shared Properties row joining the left and right tables on email as both Left Property and Right property

Employee Directory Callable: join inputs 2

You repeat this pattern for each system you wish to include in your directory, storing the final result in data storage as the last step:

Tall workflow diagram chaining Get Slack, Salesforce, Outreach and Chili users, joining each in turn, then Format the response and Update Employee Directory storage

Employee Directory Callable: full build ex

We turn this process itself into a “fire and forget” callable whose function is to “rebuild the directory” whenever we need. This allows us to have a schedule trigger which rebuilds it nightly, but also system-specific triggers that fire in real-time whenever a user is added or removed from the system so we can instantly rebuild the directory and make those updates as soon as they occur.

Schematic of the Build Directory callable: build the initial list of employees, join additional system data, divide list into pages, then store each page in account scope

Employee Directory Callable: schematic

For larger companies with many employees which would exist in the directory, there’s logic to create pages for the directory in the build process and a pagination feature in the search workflow to go through them.

Want to give it a try?

If you’re interested in building your own directory, check out our employee directory project template to get started. There’s several videos in the template documentation and a variety of helpful templates/utility workflows to simplify getting things setup.

If you’re a customer, make sure to hit us up in #workflow-help of the Slack community if you have questions.