Prompt
build agent that can update Salesforce records
Latest observation
Oct 9, 2026
OpenAI APIWeb search: off
Sure — I can help you design and build an agent that updates Salesforce records.
What the agent should do
At a minimum, it should be able to:
- Authenticate to Salesforce
- Find the target record(s)
- Update one or more fields
- Return success/failure and any updated record IDs
- Log actions for auditability
Typical architecture
1. Agent interface
- Chat/UI, API endpoint, or workflow trigger
- Accepts requests like: “Update John Smith’s phone number to 555-1234”
2. Orchestration layer
- Converts natural language into structured intent
- Validates fields, permissions, and record identifiers
- Calls Salesforce update functions
3. Salesforce connector
- Uses Salesforce REST API or Bulk API
- Supports:
- Querying records with SOQL
- Updating records via PATCH/REST
- Handling retries/rate limits
4. Guardrails
- Confirm before destructive changes
- Restrict allowed objects/fields
- Role-based access control
- Audit logging
Recommended implementation options
Option A: Custom agent with Salesforce API
Best if you want full control.
Stack example
- Backend: Python/FastAPI or Node.js
- LLM/agent framework: OpenAI Agents SDK, LangChain, or similar
- Salesforce auth: OAuth 2.0 connected app
- API: Salesforce REST API
Example flow
- User asks to update a record
- Agent identifies object, lookup criteria, and field changes
- Backend queries Salesforce to find matching record
- Agent asks for confirmation if needed
- Backend sends update request to Salesforce
Option B: Agent inside Salesforce
Best if you want tighter CRM integration.
- Use Salesforce Flow + Apex + Einstein/Agentforce tools
- Connect external services via Apex callouts
- Good for enterprise governance
Example Salesforce REST update
To update a record, you typically use:
PATCH /services/data/vXX.X/sobjects/Contact/{Id}
Authorization: Bearer {access_token}
Content-Type: application/json
{
"Phone": "555-1234"
}
Example logic in Python
import requests
def update_salesforce_record(instance_url, access_token, object_name, record_id, updates):
url = f"{instance_url}/services/data/v60.0/sobjects/{object_name}/{record_id}"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
response = requests.patch(url, json=updates, headers=headers)
response.raise_for_status()
return {"success": True, "record_id": record_id}
Safety checks you should add
- Verify the object is allowed
- Verify user has permission to update the record
- Prevent updates to protected fields
- Require confirmation for bulk changes
- Keep an audit trail of:
- who requested the change
- what changed
- before/after values
- timestamp
If you want, I can build one of these next:
- A complete Python agent example
- A Node.js agent example
- A Salesforce Flow/Apex approach
- An LLM tool-calling setup for record updates
- A production-ready architecture with auth, logging, and guardrails
If you want, I can generate a working starter project for option 1 or 4.