Inspiration
Creating quotes manually in Salesforce often involves multiple steps — selecting products, applying pricing, discounts, and associating them with the right accounts. We wanted to streamline this with natural language input, allowing sales teams to simply describe what they need, and have the system generate quotes instantly using AI (GPT-4).
What it does
The solution allows users to: ---Enter natural language instructions like “Create a quote for Acme Corp with 2x Product A and 5x Product B, apply 10% discount to Product A” ---Send this input to OpenAI using a secure Named Credential ---Receive structured JSON (account name, product list, quantities, discounts) ---Automatically generate: ---A Quote record in Salesforce ---Multiple Quote Line Items with correct pricing and discount logic
How we built it
---Lightning Web Component (LWC) to capture user input and display AI output. ---Apex Controller to securely send the prompt to OpenAI’s ChatGPT API via a Salesforce Named Credential. ---Prompt Engineering to ensure OpenAI returns structured, JSON-formatted responses. ---Apex Helper Class to parse the JSON response and create Salesforce Quote and Quote Line Item records. --Deployed the solution using Salesforce DX (SFDX) in a modular, source-driven format.
Challenges we ran into
---Parsing OpenAI response reliably: Making sure GPT always returns consistent JSON required careful prompt tuning. ---Salesforce limits: HTTP callout limits and JSON parsing guardrails meant we had to simplify inputs and error-proof the Apex logic. ---Product matching: Ensuring AI-generated product names matched existing Salesforce Product2 records using SOQL.
Accomplishments that we're proud of
---Built an end-to-end AI pipeline fully inside Salesforce with no middleware. ---Achieved a working solution that understands plain English and generates data-rich CRM records. ---Created a reusable LWC that can be embedded in Flows or Lightning pages. ---It’s modular, scalable, and secure, using Named Credentials to keep API keys safe.
What we learned
---AI can be incredibly powerful inside CRM systems — if we shape the prompts correctly. ---OpenAI and Salesforce integrate well when using Named Credentials and custom Apex logic. ---Users love talking to the system in plain language — it boosts productivity and reduces friction. ---Prompt engineering is a skill — crafting the system prompt matters just as much as writing the code.
What's next for AI based Quote eneration
---Multi-turn conversation: Let users correct or modify parts of the quote via AI chat. ---Voice input support on mobile using Salesforce Mobile SDK or Einstein Voice. ---Auto-product recommendations based on customer profile and history. ---Quote summary visualization before confirming creation. ---Einstein / Data Cloud native integration for tighter AI/CRM fusion.
Built With
- apex
- flows
- lwc
- openai
Log in or sign up for Devpost to join the conversation.