...is a Salesforce app with a Utility Bar chat component that helps org users with their daily work. Using natural language it answers questions about data, metadata and configuration. It can also perform tasks on the user's behalf, like creating or modifying records, making configuration changes or notifying other people.
- Answers questions about data, metadata and org settings
- Creates and updates data and metadata (delete not supported)
- Respects the permissions of the users
- Can explain what it does and self-correct errors
- Leverages OpenAI Assistant API (Knowledge Retrieval and State Management)
- Implements autonomous ReAct / AutoGPT agent
- Uses packageable Named Credentials for API Authentication
It behaves like a good Butler, in the sense that it does things in the background and only bugs the user when something is unclear. It also would not just do harmful things that are not in the permission of a user and could create potential harm.
This is made possible by Open AI's Assitant API, an Agent technology similar to AutoGPT or Salesforce upcoming Copilots. It uses LLM reasoning to understand a request and makes an action plan based on automations that were made available to the agent. Open AI calls them Functions or Plugins, Salesforce calls them Copilot Actions.
Those automation are not performed by the LLM but just delegated back to Salesforce, which then calls deterministic code.
This PoC shows that in the realm of Salesforce where there is a well-documented REST API for nearly everything a single Action or Function is sufficient. The Org Butler does everything it does just by constructing REST API requests as shown in this PlantUML:
- Add your own OpenAI API Key by adding a new Principal Parameter called
ApiKey
inSetup > Named Credential > External Credential > OpenAiApi.ApiKey
- Populate the Assistant Id fields in the
MyOrgButler__c Custom Settings
. There are 2 fields to differentiate between Assistants used in Dev and Production orgs. - To use the Web Search Tool get a Free Tavily API Key and put the Key also into the
MyOrgButler__c Custom Settings
.
- Create an OpenAI Assistant using Functions and Instructions like the ones we use. Find them in
openai-configs
.
- Clone the repo
- Find and replace
aquiva_os
namespace in this repo's files with your own namespace. You can also make it work without a namespace. - Create Scratch org
- Adjust the DEV_HUB_ALIAS in
/scripts/create-scratch.org.sh
- Run it via
./scripts/create-scratch.org.sh
- Adjust the DEV_HUB_ALIAS in
- Adjust the code and metadata
- Create a Managed or Unlocked package from it using
/scripts/create-package.sh
DISCLAIMER - Simple vs. sophisticated
This app was not written with a commercial career in mind. So we cut corners in a few places to keep the projects short and focused. So if you see some ugly parts here and there, let us know but be kind to us. This project is mainly about sharing results and excitement in "AI for Salesforce".
We also made some adjustments, and simplifications to the original code to better fit the Open Source purpose. To have less loose metadata parts, we:
- Skipped moving UI text to Custom Labels
- Merged classes to have the most related code in one place