Skip to main content
WhatsApp Guides

WhatsApp Flow Dynamic Car Rental Availability with n8n Webhooks

Sarah Jenkins
12 min read
Views 0
Featured image for WhatsApp Flow Dynamic Car Rental Availability with n8n Webhooks

Real-Time Inventory for WhatsApp Bookings

Static forms fail when inventory changes every minute. In the car rental industry, a vehicle available ten minutes ago might be gone now. If your WhatsApp bot shows an outdated list of cars, users feel frustrated. They complete a long form only to receive a rejection message later. This leads to high drop-off rates and lost revenue.

WhatsApp Flows solve this by allowing interactive, multi-screen experiences directly inside the chat. However, the true power of these flows lies in dynamic data. By connecting a flow to an external webhook, you fetch live data from your database while the user is still in the app. This article teaches you how to bridge that gap using n8n and external webhooks.

The Problem with Static Rental Forms

Traditional WhatsApp automation often relies on fixed templates. You ask for a pickup date, a return date, and a car class. The bot then checks the database and sends a separate message with results. This back-and-forth feels slow. It lacks the polish of a modern mobile application.

Dynamic WhatsApp Flows change this behavior. When a user selects their dates, the flow triggers a background request to your server. Your server checks the garage inventory and returns a list of available cars immediately. The user sees these cars inside the same interface. This flow requires a reliable backend to handle logic and data transformations. Many developers find building this backend from scratch difficult. That is where n8n provides a solution.

Prerequisites for Your Integration

Before you start building, ensure you have the necessary tools ready. This project requires a mix of messaging infrastructure and automation logic.

  1. A WhatsApp API Account: Use the Meta WhatsApp Business API for large-scale enterprise needs. If you prefer a developer-friendly alternative with a simpler onboarding process, consider WASenderApi. It connects a standard WhatsApp account via QR session and offers a lower barrier for testing or small-scale deployments.
  2. n8n Instance: You need a running version of n8n. Self-hosted Docker versions or n8n Cloud both work for this project.
  3. Database: A place where you store your car inventory. PostgreSQL, MySQL, or even a structured Google Sheet works for the logic layer.
  4. Publicly Accessible URL: Your n8n webhook must be reachable by WhatsApp. Use a service like Ngrok for local development or a static IP for production.
  5. SSL Certificate: WhatsApp requires HTTPS for all endpoint communications.

Step 1: Setting Up the n8n Webhook Node

The first step is creating a listener. This node waits for the WhatsApp Flow to send date and location information.

Create a new workflow in n8n and add a Webhook node. Set the HTTP Method to POST. Choose a path like /rental-availability. In the settings, ensure the node responds with a "Response to Webhook" node. This allows n8n to send the inventory data back to the flow in the specific format WhatsApp requires.

WhatsApp sends data as an encrypted payload for security. For your first prototype, disable signature verification in the WhatsApp Flow settings to test the data flow. Once the logic works, implement the decryption logic in n8n using a Function node. This ensures only Meta can trigger your inventory lookups.

Step 2: Designing the WhatsApp Flow JSON

A WhatsApp Flow consists of a JSON file that defines screens and actions. The most important part of this JSON is the data_exchange action. This action tells the flow to pause and wait for your n8n webhook to provide data.

Below is a sample structure for a car selection screen. It sends the pickup_date and return_date to your webhook.

{
  "version": "3.0",
  "screens": [
    {
      "id": "DATE_PICKER",
      "title": "Select Dates",
      "terminal": false,
      "data": {},
      "layout": {
        "children": [
          {
            "type": "DatePicker",
            "label": "Pickup Date",
            "name": "pickup_date"
          },
          {
            "type": "Button",
            "label": "Search Cars",
            "on-click-action": {
              "name": "data_exchange",
              "payload": {
                "pickup": "${form.pickup_date}",
                "return": "${form.return_date}"
              }
            }
          }
        ]
      }
    }
  ]
}

When the user clicks the Search Cars button, n8n receives a POST request. The body of this request contains the pickup and return dates.

Step 3: Engineering the Availability Logic in n8n

Once n8n receives the dates, it must perform three tasks. It validates the dates, queries the database, and formats the car list.

Start with an IF node to check if the return date is after the pickup date. If the dates are invalid, send a response back to the flow with an error message. If the dates are valid, use a database node. Your SQL query should look for cars where no existing booking overlaps with the selected timeframe.

Example SQL logic: SELECT name, price, image_url FROM cars WHERE status = 'active' AND id NOT IN (SELECT car_id FROM bookings WHERE end_date > :pickup AND start_date < :return)

This query ensures you only show cars that are physically in the garage. After fetching the rows, use a Set node to transform the database output into the specific JSON schema expected by the WhatsApp Flow screen.

Step 4: Returning Data to the Flow

WhatsApp Flows expect a specific response structure. You must tell the flow which screen to display next and provide the data for the components on that screen. Use the Respond to Webhook node in n8n for this purpose.

{
  "version": "3.0",
  "screen": "SELECT_CAR",
  "data": {
    "available_cars": [
      {
        "id": "suv_001",
        "title": "Luxury SUV",
        "description": "$85/day - All-wheel drive",
        "metadata": "85"
      },
      {
        "id": "sedan_002",
        "title": "Economy Sedan",
        "description": "$45/day - High fuel efficiency",
        "metadata": "45"
      }
    ]
  }
}

The metadata field is useful for passing price information to the final checkout screen without forcing the user to re-enter it.

Handling Edge Cases in Rental Logic

Building a robust system means planning for when things go wrong. High-volume rental systems face specific technical hurdles.

Race Conditions

Two users might select the same car at the same time. To prevent this, do not finalize the booking during the search phase. Only place a temporary hold on the vehicle once the user reaches the final confirmation screen in the flow. Use a TTL (Time To Live) lock in a database like Redis to hold the car for five minutes.

Network Latency

WhatsApp has a 10-second timeout for endpoint responses. If your database query takes longer than 10 seconds, the flow will show an error. Optimize your database indexes. Ensure your n8n instance has enough CPU resources to process the JSON quickly. If you use WASenderApi, ensure your local server has a stable connection to avoid message processing delays.

Empty Results

What happens if no cars are available? Do not return an empty screen. Use logic in n8n to redirect the user to a different screen. This screen should offer alternative dates or a button to speak with a human agent. This keeps the user engaged instead of ending the session abruptly.

Troubleshooting Common Failures

If your integration fails, check these common points of failure first.

  1. Endpoint URL Verification: When you first add your n8n URL to the Meta Developer Portal, Meta sends a GET request with a challenge parameter. Your n8n workflow must handle this GET request and return the challenge string to verify ownership. Without this, you cannot save the endpoint configuration.
  2. JSON Version Mismatch: Ensure the version field in your n8n response matches the version in your Flow JSON. If the flow is version 3.0 and the response says 2.1, the screen will not render.
  3. Data Type Errors: If a flow component expects an array but n8n sends a single object, the flow will crash. Use the Function node in n8n to wrap single results in brackets [] to maintain array consistency.
  4. SSL/TLS Version: Meta and official API providers require modern TLS (1.2 or higher). If you host n8n on an old server with outdated SSL libraries, the connection will fail.

Frequently Asked Questions

Do I need a WhatsApp Business Solution Provider (BSP) to use Flows? Yes, official WhatsApp Flows require access to the Business API. You can access this through Meta directly or via a BSP. For those looking for fewer restrictions during early development, WASenderApi offers a way to send messages and handle webhooks without the standard BSP approval process.

Is the data exchange between WhatsApp and n8n secure? Yes. Meta uses an encrypted payload for all data exchange requests. You must use your Flow's public/private key pair to decrypt the incoming data in n8n. This ensures that only Meta can read your inventory data and only Meta can send requests to your endpoint.

How many items can I show in a car selection list? WhatsApp Flows work best with lists under 20 items. Large payloads can cause slow loading times on mobile devices with poor signals. If you have a large fleet, use the n8n logic to filter results by the most popular cars or the user's previous preferences.

Can I process payments directly in the flow? While you can calculate prices and show totals, most regions require a transition to a dedicated payment gateway. You can use the final screen of the flow to send a message with a payment link or use the WhatsApp Payment API if it is available in your country.

Does n8n need to be on the same server as my database? No. As long as n8n has the correct credentials and network access to your database, it can reside anywhere. Many developers use n8n Cloud to connect to an RDS instance on AWS or a managed PostgreSQL database on Supabase.

Conclusion and Next Steps

Automating car rental availability transforms a simple chatbot into a high-performance booking engine. By using n8n as the logic layer between WhatsApp and your inventory, you create a responsive experience for your customers. This reduces the work for your staff and speeds up the rental process.

Start by building a basic flow with three screens: Date Selection, Car List, and Booking Confirmation. Once you master the data exchange, add advanced features like dynamic pricing based on the day of the week or location-specific inventory. If you want to bypass the complexity of Meta's official onboarding for your first prototype, try setting up a webhook with WASenderApi to see the interaction in real-time. This hands-on approach is the best way to understand how dynamic data flows through the WhatsApp ecosystem.

Share this guide

Share it on social media or copy the article URL to send it anywhere.

Use the share buttons or copy the article URL. Link copied to clipboard. Could not copy the link. Please try again.