Scenario-Based App Recommendations: Intent Recognition, Copywriting, and Frequency Control Practices

    This article details the design and implementation of a scenario-based application recommendation system for conversational assistants. It covers the positioning and boundaries of the system, dual-channel intent recognition, confidence thresholds, and ranking strategies. Additionally, it explains the constraints and fallback mechanisms for generating selling point copy, system architecture, data flow, frequency control, and compliance considerations to ensure a non-intrusive user experience.

    I. Positioning and Boundaries

    Scenario-based app recommendation refers to the conversational assistant determining the task type while the user is completing a task, and recommending 1 to 3 app capabilities that can solve the task, each attached with a selling point. It is a recommendation, not a replacement for the answer. If the user rejects it, the system must immediately stop such recommendations.

    Applicable conditions: The task intent is clear, and there are apps with matching capability tags.

    Non-triggering scenarios:

    1. The user only greets or the intent is unclear, such as “Are you there?”.
    2. The task involves medical diagnosis, legal disputes, psychological crises, or minors. Recommendations are strictly not made for such conversations.
    3. The user has turned off scenario recommendations, or the daily recommendation limit has been reached.

    Boundary example: If a user says “Help me write a Python function to sort by sales”, the intent is code generation, hitting the capability tag code_generate, and a desktop programming tool can be recommended. If the user says “What does this Python error mean?”, the intent is code explanation. Explanation requests are answered directly by the assistant without recommending programming tools, because the user does not need to install new tools.

    II. Intent Recognition and Matching

    2.1 Task Tag System

    Each tag contains a tag_id, English name, synonym list, positive examples, and negative examples. Initial tag examples:

    • code_generate
    • spreadsheet_process
    • slides_create
    • email_triage
    • long_doc_write

    Each tag prepares at least 100 positive examples and 100 negative examples for offline evaluation.

    2.2 Dual-Channel Matching

    The rule channel uses regex and keywords. Rules require the simultaneous appearance of “action word + object word”, such as “organize” + “spreadsheet”, or “generate” + “code”. The appearance of “code” alone does not count as a hit. The rule channel has high precision but low recall.

    The model channel uses a classification model to output the probability of each tag, taking the top 3 with the highest probabilities.

    2.3 Confidence Threshold

    • Model probability >= 0.80: Directly adopted.
    • Probability between 0.60 and 0.80: Adopted only if the rule channel also hits the same tag.
    • Probability < 0.60: Not triggered.

    The threshold is determined on the validation set. First, set a target precision (e.g., >= 0.90), then select the lowest threshold that satisfies this precision to ensure recall.

    2.4 Conflict Priority

    1. User suppression commands (e.g., “no recommendations”, “don’t recommend tools”) have the highest priority and directly stop recommendations for the current session.
    2. When rule and model results conflict, if the model probability >= 0.90, adopt the model result; otherwise, adopt the rule result.
    3. Every conflict is written to a log, recording results from both sides for weekly review.

    2.5 Cold Start

    • New apps lack exposure data, so the ranking score is determined solely by capability tag matching. The daily exposure limit for new apps is set to 100 times, with 5% exploration traffic reserved. Data adjustments are made after a week of observation.
    • New users lack preference data, so personalized features are not used; results are sorted only by task relevance.

    2.6 Ranking and Top-N

    Candidate apps are sorted by a comprehensive score, taking the top N, where N is 1 to 3. Initial weight example:

    Comprehensive Score = 0.6 × Task Relevance + 0.2 × App Quality Score + 0.2 × User Category Preference Score − 0.1 × Rejection Count in the Last 7 Days

    The weights are just a starting point and need adjustment based on offline evaluation results and online rejection rates. Offline evaluation metrics include recommendation precision, coverage, and Top-3 hit rate.

    III. Constraints and Fallback for Selling Point Copy

    3.1 Character Counting

    Count uniformly by Unicode code points. Chinese characters, English letters, numbers, punctuation, and spaces all count as 1 character. The generated result first removes leading and trailing whitespace, then counts, with an upper limit of 90 characters. The counting function keeps only one implementation, shared by both frontend and backend using the same test cases to avoid missing full-width punctuation.

    3.2 Sentence and Content Constraints

    • Only write one sentence, with end punctuation appearing only once, at the end.
    • Must include an action corresponding to the capability tag, such as “fill in null values” or “generate formulas”.
    • No absolute words, such as “definitely”, “100%”, or “best”.
    • No phone numbers, links, prices, or promotional information.

    3.3 Four-Layer Validation

    1. Length validation: Exceeding 90 characters directly fails.
    2. Sentence count validation: Detects the number of end punctuation marks.
    3. Sensitive and banned word filtering: A hit directly fails.
    4. Capability consistency validation: The function mentioned in the copy must be within the app’s capability tags. Brand names must come from a whitelist.

    3.4 Generation and Fallback

    If model generation fails, retry up to 2 times, each retaining the same constraints. If still failing, use a template:

    "{App Name} can help you {capability verb} {object}."

    Template results must also pass length and sensitive word validation. If the template still fails, do not display the app and return reason_code = copy_failed.

    3.5 Dynamic Generation Example

    Input: Current task summary is “clean null values in the forecast data table and build a formula column”, app capability tags are spreadsheet formulas, data cleaning.

    Output example: “I can directly fill in the null values in your table and set up the forecast formulas.”

    This sentence depends on the current task and cannot be reused as a fixed ad copy in other scenarios.

    IV. System Architecture and Data Flow

    4.1 Components

    1. Context Collector: Reads the latest 3 turns of user input, desensitizes them, and passes them downstream without saving the original text.
    2. Intent Recognizer: Rule channel + classification model, outputs tags and probabilities.
    3. Capability Registry: Saves app ID, capability tags, quality score, and launch status.
    4. Matching & Ranking Module: Queries the registry, calculates comprehensive scores, and takes Top-N.
    5. Frequency Control Module: Checks limits across three dimensions: session, user, and app, filtering candidate apps.
    6. Copy Generator & Validator: Executes the process in Section III.
    7. Feedback Recorder: Receives impression, click, dismiss, and disable events, writing them to a statistics table.

    4.2 Data Flow

    User message → Context Collector → Intent Recognizer → Matching & Ranking Module (reads Capability Registry) → Frequency Control Module → Copy Generator & Validator → Return to Frontend

    Frontend impression, click, dismiss events → Feedback Recorder → Statistics Table

    Every step has a fallback strategy: if intent recognition fails, no recommendation is made; if the frequency control service is unavailable, no recommendation is made by default; if copy generation fails, the app is skipped.

    4.3 API Fields

    Recommendation API request example:

    1. {
    2. "session_id": "s_20261123_8f3a",
    3. "user_hash": "u_9c21e7",
    4. "turns": [{"role": "user", "text_masked": "Help me fill the null values in this spreadsheet"}],
    5. "locale": "en-US",
    6. "trace_id": "t_7d2e01"
    7. }

    Recommendation API response example:

    1. {
    2. "recommendations": [
    3. {"app_id": "sheet_assist_01", "copy": "I can directly fill in the null values in your table.", "score": 0.82}
    4. ],
    5. "reason_code": "ok",
    6. "trace_id": "t_7d2e01",
    7. "rule_version": "2026.11.1",
    8. "model_version": "intent-v3"
    9. }

    reason_code enum values: ok, no_intent, below_threshold, frequency_capped, user_suppressed, copy_failed, service_degraded.

    Feedback event example:

    1. {"event": "impression", "trace_id": "t_7d2e01", "app_id": "sheet_assist_01", "ts": "2026-11-23T08:35:00Z"}

    event values are impression, click, dismiss, or disable_feature.

    4.4 Frequency Control Keys and State Tables

    State Key Format TTL Rule
    Intra-session app deduplication rec:session:{session_id}:app:{app_id} Expires after 2 hours of inactivity Same app recommended at most 1 time per session
    User daily impression count rec:user:{user_hash}:day:{yyyymmdd} 48 hours No more than 5 impressions per day
    User category dismissal pref:user:{user_hash}:dismiss:{tag_id} 30 days After 1 dismissal, max 1 recommendation for this category in 7 days; after 3 dismissals, no recommendations for this category in 30 days
    App hourly rate limiting rec:app:{app_id}:hour:{yyyymmddHH} 2 hours Prevents a single app from being over-recommended
    Recommendation switch pref:user:{user_hash}:enabled Persisted Users can modify at any time

    The numbers in the table are initial settings and need to be adjusted based on business data.

    V. Monitoring Metrics

    • Trigger rate: The proportion of recommendation requests returning at least 1 app out of all recommendation requests.
    • Click-through rate (CTR): Clicks divided by impressions.
    • Dismissal rate: dismiss events divided by impressions.
    • Turn-off rate: disable_feature events divided by active users.
    • Copy failure rate and template fallback rate.
    • API P95 latency, target value set by the engineering team.

    Alert example: If the dismissal rate exceeds 15% continuously for 1 hour, or the turn-off rate increases by 50% day-over-day, manual inspection is triggered.

    VI. Common Failure Cases

    1. False trigger. The user said, “What does this variable name in the code mean?” The old rule only matched the word “code”, so a programming tool was recommended. The fix was to change the rule to the “action word + object word” combination and separately label explanation requests as non-recommendable.
    2. Copy too long. During development, counting was done by bytes, where each Chinese character was counted as 3 bytes, causing qualified copy to be falsely judged as too long. Also, full-width punctuation was missed. The fix was to uniformly count by Unicode code points and add test cases for full-width punctuation.
    3. Frequency control failure. The frontend generated a new session_id for each conversation turn, causing session deduplication to fail, and the same app appeared 5 times in one conversation. The fix was to keep the session_id constant throughout the session and validate its format on the server side.
    4. Preferences stored original text. To personalize, the original user question was written into the preference table, posing a privacy risk. The fix was to only store tag counts and app IDs, not original text, and set a 90-day expiration.

    VII. Compliance and Anti-Disturbance Checklist

    1. Context minimization: Recommendations only read the latest 3 turns of user input. Phone numbers, ID numbers, emails, addresses, and names are desensitized before being passed to the model. Original text is not persisted.
    2. Preference storage period: Category-level preferences are retained for 90 days and automatically deleted after inactivity.
    3. User control: The settings page provides a “Turn off scenario recommendations” switch. Once turned off, recommendations stop immediately and preference writing ceases. A “Clear recommendation history” entry is provided; clearing it deletes all data for that user in the preference table.
    4. Sensitive scenario prohibition: No recommendations are made for conversations related to medical, legal, psychological crises, and minors.
    5. Audit: Each recommendation records trace_id, rule version, model version, reason_code, and app ID, retained for 30 days for troubleshooting. Original conversations are not recorded.
    6. Numerical description: The retention periods and deletion timeframes above are examples only. Final values must be confirmed by the legal and privacy teams.
    7. Anti-disturbance: Same app recommended at most 1 time per session; no more than 5 impressions per day; recommendation frequency for a category is reduced after user dismissal.

    VIII. Launch Acceptance Checklist

    1. Offline evaluation: At least 100 positive and 100 negative examples for each tag. Labeling consistency must reach the team’s agreed level before use in evaluation.
    2. Copy testing: Covers five types of test cases: extra-long text, full-width punctuation, sensitive words, multi-sentence input, and empty output, all passing.
    3. Frequency control testing: Simulate repeated requests in the same session to confirm the same app appears only once; simulate cross-session requests to confirm the daily limit takes effect.
    4. Grayscale launch: First open 5% traffic and compare with the control group. If the dismissal rate is higher than the control group and lasts for 3 days, roll back to the previous version of rules and models.
    5. Fallback drill: Turn off the intent recognition service and frequency control service to confirm the API returns no_intent or service_degraded, and the frontend displays the normal answer properly.