Skip to main content

Developer Guide

This guide describes the data model and API for Style Suggestions in Deepdesk Agent Assist.

Data Model

StyleSuggestion

The configuration model for a style suggestion rule stored in the database.

FieldTypeRequiredDescription
idintegerYesUnique identifier for the style suggestion
titlestringYesShort title describing the style rule
messagestringYesThe suggestion text shown to agents
keywordsarray[string]YesList of keywords or phrases that trigger this suggestion

Schema Definition:

class StyleSuggestion(BaseModel):
id: int
title: str
message: str
keywords: list[str]

KeywordMatch

Represents a detected keyword match in an agent's message.

FieldTypeRequiredDescription
keywordstringYesThe matched keyword or phrase from the message
titlestringYesTitle of the triggered style rule
suggestionstringYesThe guidance text to show the agent

Schema Definition:

class KeywordMatch(BaseModel):
keyword: str
title: str
suggestion: str

API Reference

Detect Style Suggestions

Detects style breaks in a message for a given profile and returns matching suggestions.

POST /api/v2/style-suggestions

Request Body

FieldTypeRequiredDescription
profile_codestringYesThe profile code to load style rules for
messagestringYesThe agent message to analyze

Request Schema:

class StyleSuggestionRequest(BaseModel):
profile_code: str
message: str

Authentication

This endpoint requires one of the following authentication methods:

  • OAuth2 with conversations:read scope
  • Bearer token (HTTPBearer)
  • API Key Cookie (access_token_cookie)

Response

Returns a StyleSuggestionResponse containing matched keywords.

Success Response (200 OK):

{
"keyword_matches": [
{
"keyword": "can't",
"title": "Avoid negative phrasing",
"suggestion": "Try phrasing in positive terms, e.g., 'We are able to...' instead of 'We can't...'"
}
]
}

Response Schema:

class StyleSuggestionResponse(BaseModel):
keyword_matches: list[KeywordMatch]

Error Response (422 Validation Error):

{
"detail": [
{
"loc": ["body", "profile_code"],
"msg": "field required",
"type": "value_error.missing"
}
]
}

Example Request

curl -X POST "https://api.deepdesk.com/api/v2/style-suggestions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"profile_code": "retail-en",
"message": "We can'\''t process this kind of request right now."
}'

Architecture Overview

  • Backend exposes a REST API (POST /api/v2/style-suggestions) for keyword detection
  • Frontend displays style suggestions to agents and sends a "style suggested" event
  • When an agent sends a message, the ingestion pipeline detects style breaks and sends a style breaks found event

Detection Logic

The style detection engine uses the following rules:

  • Case-insensitive regex search
  • Word boundaries are enforced so partial words do not trigger (e.g., can won't match inside candy)
  • Multi-word keywords are supported; spaces in the keyword are matched with \s+ for flexible whitespace
  • Quote characters in keywords are relaxed to match similar quote styles
  • Template placeholders wrapped in curly braces { ... } are ignored via negative lookbehind/lookahead

Analytics

For reporting, Deepdesk tracks style suggestion usage and compliance. When the backend detects style breaks in agent messages, it emits the style breaks found event to the analytics pipeline.

Event Destinations:

DestinationTable/Dataset
ClickHouseevents table
BigQuery (deprecated){PROJECT}.{ACCOUNT_CODE}_analytics_dataset.events_v2

Event Payload Fields:

FieldDescription
event_idUnique event identifier
conversation_idAssociated conversation ID
profile_codeProfile code for the conversation
platform_session_idCX platform session ID
platformCX platform identifier
agent_*Agent-related fields (ID, name, email)
time_utcISO 8601 timestamp
dataJSON string containing {"style_breaks": [{"title", "trigger"}]}
info

The event payload contains the external agent ID as received from the CX platform.

OAuth2 Scopes

ScopeDescription
conversations:readRequired for detecting style suggestions

Operational Notes

  • Only suggestions that are ENABLED and associated with the relevant Profile will be effective
  • Curate keyword lists to minimize false positives; prefer specific phrases where possible
  • For dynamic placeholders in templates, wrap them in {} to avoid matching as style breaks

For an overview, see the Overview. For agent usage, see the User Guide.