You can run this code locally or via Docker (see sections below).
Please read the entire README before beginning.
If you wish to visualize the database, consider installing MongoDB Compass or Robo 3T
NOTE: You will need to use docker-compose to spin up the Mongo Database
client
└── engagement
└── interaction
This is self-explanatory. We have many clients who use the Topbox platform. This is where all global client properties reside.
- _id (unique id - automatically generated by Mongo)
- name
- nickName (shortened version of name)
The engagement collection is a logical separation of upstream client data. This allows us to separate client data by source: Twitter, Facebook, Phone Support, or Chat Support (it really just depends on what data the client wants to ingest into Topbox)
- _id (unique id - automatically generated by Mongo)
- clientId (foreign key: the client the engagement is associated with)
- name (name of the engagement: SMS, Chat, Facebook, Phone, etc.)
The interaction
collection is where all custom client data is written to. This could be a chat log from an online chat session,
a support phone call for a returned pair of shoes, or a tweet from Twitter.
- _id (unique id - automatically generated by Mongo)
- engagementId (foreign key: the engagement which the interaction data is associated with)
- agentName (the agent who made the phone call, the support agent who was in the chat session, etc.)
- interactionDate (the timestamp for the customer interaction - i.e. when a phone call began, when a tweet was sent)
- custom (this sub-document is where all original source data is dumped - agent name, csv name, etc.)
docker-compose build
docker-compose up
docker-compose exec web python3 /web/mock_data/seed.py
docker-compose down # tear down stack
This repo should work with Python 3.6, 3.7, and 3.8
pip3 install -e .
export MONGO_URI=mongodb://admin:adminpass@localhost:27017/production?authSource=admin
FLASK_APP=app/app.py flask run --port 5001
export MONGO_URI=mongodb://admin:adminpass@localhost:27017/production?authSource=admin
python3 mock_data/seed.py
curl localhost:5000/clients
Querying /interactions/<interaction_id>
Will return the following
{
"_id": {
"$oid": "5f18d12f42262eec0d43567d"
},
"engagementId": {
"$oid": "5f18d12f42262eec0d435583"
},
"interactionDate": {
"$date": 1589630400000
},
"agentName": "John Ford",
"sentiment": "Negative",
"custom": {
"csvName": "2020_16_05_report.csv",
"agentFirstName": "John",
"agentLastName": "Ford"
}
}
NOTE: This is BSON-encoded JSON (as you can see by the "$date"
and "$oid"
fields... BSON encoding works fine for this API)