The webhook payload
Incoming messages arrive as webhook events whose entry[].changes[].value holds contacts (the customer's profile name and WhatsApp id), messages (each with from, id, timestamp, type and a body for its type) and statuses for messages you sent. Store each message, group them into a conversation per customer, and let your AI respond.
Showing the 24-hour window
Because free-form replies close 24 hours after the customer's last message, show the remaining time on WhatsApp conversations in the inbox, and switch the reply box to template messages when it closes.