This project demonstrates how to integrate the MAC project's modules and connectors for your Mule projects.
Connect to your Agentforce Agent via API.
- Conversation
- Start
- Continue
- End
Use the Einstein AI trust layer to make use of different models from Einstein.
- Agent
- Define Prompt Template
- Chat
- Answer Prompt
- Generate From Messages
- Embeddings
- Adhoc File Query
- Generate From File
- Generate From Text
- RAG
- Adhoc Load Document
Tip
Agent, Chat and RAG make use of LLMs to give an answer in natural language, whereas Embeddings will give numeric responses since no LLM is being used.
Tools - Use AI Service operation is not included in this project.
- Salesforce org - Create a new dev account here
- MuleSoft IDE - Anypoint Studio or Anypoint Code Builder
Note
Based on these instructions.
- Open your Salesforce org and to go Setup.
- From setup, use Quick Find to search for App Manager.
- Click New Connected App and then select Create a Connected App.
- Specify a Connected App Name like
mac_project
. - Add your contact email. Make sure it's a real email, you'll need it later.
- Check Enable OAuth Settings ✅
- Callback URL:
https://login.salesforce.com
- Selected OAuth Scopes. Do NOT select more scopes or you'll get a scope error:
- Access chatbot services (chatbot_api)
- Access the Salesforce API Platform (sfap_api)
- Manage user data via APIs (api)
- Perform requests at any time (refresh_token, offline_access)
- Deselect/select the following settings:
- Require Proof Key for Code Exchange (PKCE) Extension for Supported Authorization Flows ◻️
- Require Secret for Web Server Flow ◻️
- Require Secret for Refresh Token Flow ◻️
- Enable Client Credentials Flow ✅
- Enable Authorization Code and Credentials Flow ◻️
- Enable Token Exchange Flow ◻️
- Enable Refresh Token Rotation ◻️
- Issue JSON Web Token (JWT)-based access tokens for named users ✅
- Introspect All Tokens ◻️
- Save the app and click Continue.
- Once you're in the Manage Connected Apps page, click Manage.
- Click Edit Policies.
- Permitted Users: All users may self-authorize
- Enable Single Logout ◻️
- Run As
<select your user, in my case, Alex Martinez>
- Issue JSON Web Token (JWT)-based access tokens ✅
- Token Timeout: 30 Minutes
- Go back to the connected app and click Manage Consumer Details.
- Add your verification code from your email.
- Click generate and then apply.
- Copy the consumer key/secret from the top. You will use these in MuleSoft.
- In Setup, go to Einstein Setup and turn on Einstein.
- Wait a few seconds and refresh the site. You might not see the following options if you don't refresh.
- Look for Agentforce Agents and turn on Agentforce.
- Enable the Agentforce default Agent.
- In Agentforce Agents, click on New Agent.
- Create from a Template > Agentforce Service Agent
- Remove all the topics to start from scratch
- (optional) Add the Off Topic topic with the information from off-topic.md
- Add the following details:
- Name:
Agentforce MuleSoft Agent
- API Name:
Agentforce_MuleSoft_Agent
- Description:
Use custom topics and actions to connect to your MuleSoft APIs.
- Role:
An AI customer service agent who connects to MuleSoft APIs for custom functionality.
- Company:
This company is used for demo purposes.
- Name:
- Don't add Data Cloud resources for this example.
- Once the agent is created and you have it open, click Connections.
- Click on Add to add a new connection.
- Select API, add an integration name like
MAC Project Integration
and select the connected app you previously created (mac_project
). - Once you add the connection, make sure to click on Activate at the top-right of the screen.
Important
The Mule API cannot call Agents that are deactivated. Make sure that it's Active in Salesforce. BUT anytime that you need to modify the agent, you have to deactivate it first.
Copy the dev-properties.yaml file and create a local-properties.yaml
file.
Configure your environment and Salesforce credentials:
domain: YOUR_SALESFORCE_ORG_DOMAIN
clientId: YOUR_CONNECTED_APP_CLIENT_ID
clientSecret: YOUR_CONNECTED_APP_CLIENT_SECRET
Your Client ID / Secret is the same from your Connected App's Consumer Key / Secret.
You can obtain your Salesforce Org's domain from Salesforce Setup > My Domain > Current My Domain URL. For example: orgfarm-6acf46e05z-dev-ed.develop.my.salesforce.com
- Import the project into Anypoint Studio or Anypoint Code Builder.
- Ensure your
local-properties.yaml
is correctly configured. - Run the Mule application.
You can find the HTTP requests in requests/. I am using the REST Client extension in VS Code to run these from the text editor, but you can use Postman, cURL, or any other REST Client you prefer.
- Authentication errors: Double-check your Client ID, Client Secret, and Connected App settings.
- Scope errors: Make sure the scopes in your Connected App are set up correctly. If you add more/less scopes than the mentioned in the settings here, you might get scope errors.
- Network issues: Ensure your Mule server can reach Salesforce.