in backend-apis/app/routers/p5_contact_center_analyst.py [0:0]
def get_customer_info(customer_id: str) -> Customer:
"""
# Retrieve customer information from Firestore
- CDP data
- Conversations
- Reviews
## Request Parameters:
**customer_id**: *string*
- Unique identifier of the customer
## Customer:
**conversations**: *list*
- List of all the conversations that customer had with the Call Center
**reviews**: *list*
- List of all the reviews submited by that customer
**customer_info**: *dict*
- Information about that customer extracted from the CDP
"""
customer_info = (
db.collection(config["search-persona5"]["firestore_customers"])
.document(customer_id)
.get()
)
if customer_info:
customer_info = customer_info.to_dict() or {}
else:
raise HTTPException(status_code=400, detail="Customer ID not found.")
conversations = (
db.collection(config["search-persona5"]["firestore_conversations"])
.where(filter=FieldFilter("customer_id", "==", customer_id))
.get()
)
conversations_list = []
for conversation in conversations:
conversations_list.append(conversation.to_dict())
reviews = (
db.collection(config["search-persona5"]["firestore_reviews"])
.where(filter=FieldFilter("customer_id", "==", customer_id))
.get()
)
reviews_list = []
for review in reviews:
reviews_list.append(review.to_dict())
return Customer(
conversations=conversations_list,
reviews=reviews_list,
customer_info=customer_info,
)