Count Billable WhatsApp Business Conversations with Rolling Windows

Last updated: November 29, 2026

Quick Overview

A WhatsApp Business conversation opens when a business sends a message to a user while no conversation with that user is open, and it stays open for 24 hours from that message. Given message logs, count conversations per business.

Meta
Data Manipulation (SQL/Python)
Data Scientist
Meta
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


A WhatsApp Business conversation opens when a business sends a message to a user while no conversation with that user is open, and it stays open for 24 hours from that message. Given message logs, count conversations per business.

Fits Meta's onsite data manipulation interview for teams that support WhatsApp Business monetization, where windows that are anchored on an event (not on a gap) are the core idea. The interviewer checks that you notice why this cannot be done with a simple gap rule and that you handle the boundary carefully.

What the Interviewer Expects
  • Recognizes the window is anchored to the opening message, not to the last message
  • Processes messages in time order per (business, user)
  • Ignores user messages for opening, per the stated rule
  • Handles the exact 24-hour boundary deliberately
  • Explains why a pure SQL LAG approach fails and what would work instead
Key Topics to Cover
anchored windows
stateful iteration
sessionization
WhatsApp Business
boundary conditions
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you implement this in SQL, given that it is recursive by nature?
  • How would the logic change if user-initiated and business-initiated conversations are priced differently?
  • How would you parallelize it across billions of messages?
  • What if messages arrive late and out of order in the stream?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Rows are (business_id, user_id, sender, ts). Rule: a business message opens a new conversation if there is no open one for that pair, and the conversation covers [open_ts, open_ts + 24h). Business...

Approach

This is different from gap-based sessionization. With a 30-minute gap rule, each message extends the session; here the window is fixed from the opener, so a business messaging every 23 hours gets a ne...


Submit Your Answer
Markdown supported