Skip to content

Handle ambiguous / missing data in WhatsApp messages + structure for "Last 2 Entries" #3

Description

@square-story

When users send very short or vague messages, the bot should intelligently ask for the missing piece of information instead of failing or guessing. This is important for real-world WhatsApp usage where people type in shorthand.

1. Ambiguous / Missing Data Flows

Scenario A: Missing Name

  • Input: Gave 500
  • Problem: No customer name or identifier is provided.
  • Expected reply:
    ❓ Who is this for? Please reply with the name (e.g., "For Raju").

Scenario B: Missing Amount

  • Input: Raju came to shop
  • Problem: No amount and unclear whether it is a give/receive transaction.
  • Expected reply:
    ❓ I see Raju is here. Did you Give money or Receive money? Please mention the amount.

Acceptance criteria

  • Bot detects when:
    • Amount is missing but customer is known.
    • Customer is missing but an amount/action is present.
  • Bot responds with a single, clear follow-up question instead of a generic failure.
  • Conversation state is preserved so the follow-up answer can complete the original intent.

2. Data Structure for "Last 2 Entries" (Balance Inquiry)

For balance inquiries, the customer lookup (for example CustomerRepository.findByPhone) should return a structured view including the current balance and recent transactions.

interface CustomerProfile {
  id: string;
  name: string;
  currentBalance: number;
  lastTransactions: {
    amount: number; // negative for given, positive for received
    date: Date;
    description: string;
  }[];
}

Usage

  • For "Balance Inquiry" flows, show:
    • Current balance.
    • Last 2 transactions from lastTransactions[0..1] with amount, date, and description.

Implementation tasks

  • Extend the parser / NLU to detect missing name vs missing amount vs missing direction (give/receive).
  • Add follow-up question templates for each ambiguity type.
  • Implement the CustomerProfile view in the repository layer.
  • Update the balance inquiry handler to use lastTransactions for the "Last 2 Entries" section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions