Ujjwal TiwariEnterprise Architect
All posts

Article

Building an AI-Powered Vehicle Rental Assistant using Salesforce Agentforce

  • Salesforce
  • Agentforce
  • AI Architecture
  • Salesforce Flow

Introduction

I recently built an AI-powered vehicle rental assistant using Salesforce Flow and Agentforce.

The goal wasn't to create just another chatbot. Instead, I wanted to build something closer to a real system — one that can handle workflows end-to-end, maintain data consistency, and behave predictably even when users modify or cancel requests.


The Problem

Most AI assistants today are good at answering questions, but they often struggle with executing complete business workflows. In a typical vehicle rental scenario, the system needs to seamlessly coordinate:

  • Booking creation
  • Transaction modifications (such as operational date shifts)
  • Full cancellations
  • Live inventory management
  • Customer communications

Without deterministic coordination behind the scenes, letting an LLM loose on transactional data can quickly lead to inconsistent state mutations, double bookings, or a broken user experience.


Data Model

To ensure transactional rigidity, the data architecture relies on two critical custom entities:

1. Rental Vehicle

This object represents the physical live inventory in the system.

  • Key Attributes: Vehicle Type, Seating Capacity, Daily Rate, Location, Availability Status.

Rental Vehicle Schema

2. Rental Booking

This operational object tracks transactions and maps specific customer contact records directly to available assets.

  • Key Attributes: Contact Lookup, Rental Vehicle Lookup, Start & End Dates, Total Days, Total Amount, Booking Status.

Rental Booking Schema


Flow Architecture & State Machine

The AI agent doesn't write to the database directly. Instead, Agentforce acts strictly as an intelligent routing mechanism that triggers deterministic, single-responsibility Salesforce Flows.

Create Booking Flow

This core automation captures unstructured intent, queries inventory, matches or creates the customer contact record, locks in the calculation matrix, creates the booking record, and atomically flips the associated vehicle state to Reserved while firing off an automated confirmation email.

Create Booking Flowchart

💡 Architectural Note: Binding the vehicle state mutation directly to the atomic creation step of the booking record ensures complete transactional isolation and eliminates race conditions.

Modify Booking Flow

This workflow fetches the active booking, applies updated date bounds, re-runs duration and pricing logic, updates the transaction, and fires an alert. To prevent unintended side effects on inventory availability, this flow intentionally avoids touching the asset record itself.

Modify Booking Flowchart

Cancel Booking Flow

This flow safely rolls back the entire reservation state machine, updating the target booking status to cancelled, releasing the linked vehicle asset back to an Available status, and triggering an automated notification.

Cancel Booking Flowchart

Core Utility Automations

To support the main operations, the backend relies on two specialized query actions:

  • Find Vehicle by Capacity: Filters active inventory where seating capacity strictly satisfies the requirement and availability matches. Find Vehicle by Capacity

  • Fetch Past Bookings: Retrieves existing records linked to the verified user session to provide historical context to the agent. Fetch Past Bookings


The Agentforce Orchestration Layer

Agentforce serves as the intelligent natural language interface wrapped around this core logic. Instead of building messy, fragile conversational rules, the agent maps user requests cleanly to the structured actions based on natural language intent:

  • "I need to rent an SUV" ➡️ Create Booking Flow
  • "Change my pickup dates" ➡️ Modify Booking Flow
  • "Cancel my reservation" ➡️ Cancel Booking Flow

Marketing Automation Integration

To extend the system beyond standard operations, I integrated a proactive marketing journey block. When the transaction engine processes a booking extending beyond 10 days, the data engine automatically flags the contact record for long-term loyalty segmentation, sending an automated campaign highlighting annual memberships.

Marketing Automation Journey


End-to-End Flow Validation

Booking Creation Execution

User creates a booking ➡️ system assigns vehicle ➡️ vehicle is marked Reserved ➡️ confirmation email is sent. Booking Creation Example

Modification Execution

User updates dates ➡️ booking updates ➡️ vehicle remains unchanged ➡️ update email is sent. Booking Modification Example

Cancellation Execution

User cancels ➡️ booking status changes ➡️ vehicle becomes Available again. Booking Cancellation Example


Key Architectural Takeaways

  • Decoupled Responsibilities: Each sub-flow handles exactly one transaction domain.
  • Deterministic Core, Flexible Interface: The LLM manages the context and conversational handoff, while underlying platform code preserves database sanity.
  • State Synchronization: Inventory states are tied completely to the lifecycle of the transactional record.

Ultimately, this implementation highlights that building an effective AI agent is less about tuning the conversational layer and more about engineering a resilient, highly structured data and process automation core.