Neo4j CX Demo
Introduction
Customer Experience (CX) is everything that an organization does to deliver the best experience and value to their customers and is often thought of as a series of customer journeys, beginning from the first touchpoint a prospective customer has with the organization. CX has become a key way for organizations to differentiate themselves from their competitors, especially in an era where consumers have high expectations beyond just the capabilities of a particular product or service
In order for organizations to offer an excellent experience, a key requirement is to understand everything about their prospects and customers; this means that organizations need to combine and connect data from many different sources such as:
-
CRM and sales management applications
-
Marketing systems
-
Web interactions (including online purchases and browsing)
-
Service and Support systems
-
Inbound and outbound communications
-
Data enrichment providers
Legacy approaches to CX face significant technical challenges; these approaches usually revolve around creating a data mart/data warehouse of Customer data in a relational database. This leads to issues such as:
-
Rigid, inflexible schemas make it difficult to combine data from multiple sources and to adapt as data changes and new sources of information become available
-
Common patterns of customer behavior are hidden because of how the data is stored in rows and columns - without key connections and relationships
-
It is difficult to get a complete understanding of a customer because their data is scattered across multiple systems, each with their own identifiers (some data can even be considered anonymous - such as unauthenticated web browsing)
-
Organizations cannot operate at “web speed” (for example, to recommend products in real-time) because of the complex queries with lots of joins that are needed are slow and resource-intensive
-
Key algorithms (such as community detection, node centrality, similarity detection, etc.) need data and relationships to be prepared and organized in graphs - not rows and columns. This requires tedious data engineering work when data is stored in tables With Neo4j Graph Database and Algorithms, you can uncover insights at unprecedented speeds and increase customer lifetime value by enhancing the value of your existing solutions. Neo4j Graph Database helps you create a comprehensive view of all your customer touchpoints and interactions. It combines structured and unstructured data in an intuitive graph that makes it easy to resolve entities across channels, enhance customer segmentation models, and identify key patterns that move the needle in your business.
This demonstration shows how to use Neo4j graph database and algorithms to enrich your customers’ experience; in it, you will learn:
-
How to set up a Neo4j AuraDB instance with sample data
-
How to use graphs for entity resolution, finding duplicated representations of customers
-
How to use a graph of purchase behavior to segment customers, enabling you to offer recommendations based on common behaviors in the segment
-
How to use a graph to identify customers at risk of churning
Prerequisites
To run these examples, you will need the following:
-
Web browser and Internet access.
-
A Neo4j AuraDB database instance. These examples will run on any tier, including the Free and Professional tiers (including the free trial). You can sign up for AuraDB here. Following the instructions in this demo will replace the data in your database instance, so be sure to back up any data you do not want to lose; alternatively, you can create a fresh instance to use.
-
(Optional, but strongly recommended) a Python installation in which you can run Jupyter Notebooks. The queries for this demonstration are all provided in Notebooks; you can also copy-and-paste the queries into the Query or Explore tools in the Aura console.
-
(Optional, but recommended) git client software to download the demo assets.
-
Optional: a local setup of Cypher Workbench, if you want to experiment with tools for editing the data model.
Setting Up
-
Ensure you have a Neo4j AuraDB instance running. If you are new to AuraDB, create an account here, then click Create Instance. This demo uses graph algorithms, so you will not be able to use a Free instance. You can, however, use a free Pro trial. When you create the instance, be sure to enable the graph analytics libraries in your instance:

Be sure to save the credentials to log in to your database instance. Wait for the instance status to reach “RUNNING” before proceeding to the next step.
-
Clone the git repository from https://github.com/neo4j-product-examples/demo-cx You can do this with the following command:
git clone https://github.com/neo4j-product-examples/demo-cx.git
Alternatively, you can use the “download ZIP” option on GitHub to download a copy.
-
Using the “3 dots” menu in the Aura console, select Backup & Restore.

4. Use either the Browse button or drag-and-drop to find the dump file in the dump directory of the git repository you cloned in step 2.

-
Review the warning about replacing your instance data and proceed when you are ready:

-
You are ready to run the examples when your database instance reaches the “RUNNING” state.
-
Ensure you have the following python libraries installed:
-
python-dotenv
-
neo4j
-
neo4j-tools
-
neo4j-viz
-
-
In the src directory of your git working copy, make a copy of the cx.env.template file, name it “cx.env” and edit the file to include the URI and password for your AuraDB instance.
The Graph Data Model
The figure below shows the data model used to illustrate the CX concepts:

The key types of entities (also called labels) in this graph include:
-
Customer - Customers who purchase from us
-
Order, OrderLineItem - Customer orders and the line items in the order
-
*Product - *Products we sell to our customers
-
Country - Countries where our customers are located
-
Phone, Identifier, EmailAddress - Identifiers associated with our customers
If you would like to experiment with the data model in Cypher Workbench, you can find a copy of the data model export in model/Customers_model.json in the copy of the repository
Graphs for CX
This demonstration consists of three scenarios, each of which has its own Jupyter notebook that walks through the scenario. The three scenarios are:
-
Entity Resolution (src/entity_resolution.ipynb) - in this scenario, you will see how a graph database plus graph algorithms can help you identify customers that are represented multiple times in the data. Resolving the duplicate entries will help you by giving you a complete and accurate view of your customers, instead of the activity being fragmented across multiple customer records.
-
Churn Analysis (src/churn.ipynb) - in this scenario, you will look for patterns that indicate customers who are at risk for churning.
-
Segmentation / Recommendations (src/segmentation.ipynb) - in this scenario, you will divide the customer base into segments based on their behavior. This will help you identify common customer journeys and, for example, recommend products and services to a customer based on what other successful customers in the segment have purchased.
To run any of these scenarios, open the corresponding Jupyter Notebook and walk through the instructions and queries therein. If you would like to explore the query results more interactively, you can also run the queries in the Explore tool of the Aura console - you will be able to expand and hide relationships interactively, helping you explore the data and refine your analysis.
Next Steps
Now that you have seen how you can use Neo4j Graph Database to enrich your customers’ experience, here are some ideas for your next steps:
-
Load your own data into the same graph data model and run the same queries from this demo. An easy way to do this is to create relational tables or CSV files that match the format of the files in the data directory of the repository and use model/Neo4j_importer_model.json to load the data using AuraDB’s data import service
-
Explore another Customer Experience demo that uses Generative AI