This project demonstrates how to integrate some of the MuleSoft AI Chain 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.
Build a unification layer for LLMs, vector stores (in-memory), and AI Services.
- Agent
- Define Prompt Template
- Chat
- Answer Prompt
- Answer Prompt with Memory
- Embeddings
- New Store
- Add Document to Store
- Add Folder To Store
- Query From Store
- Get Info from Store
- Image Generation
- Read
- Generate
- RAG
- Load Document
- Sentiment Analysis
- Analyzer
- Tools
- Use AI Service
Long-term successor of MuleSoft AI Chain Connector
A connector toolkit that provide web crawling capabilities to extract data from web pages.
- Crawl
- Website (Full Scan)
- Get Sitemap
- Page
- Download Document
- Download Image
- Get Content
- Get Insights
- Get Meta Tags
- Search
Support Speech-to-text and text-to-speech to enhance other MuleSoft AI Chain connectors.
- Salesforce org - Create a new dev account here
- Anypoint Platform account - Create a free trial account here
- MuleSoft IDE - Anypoint Studio or Anypoint Code Builder
- Mule Runtime 4.9.x
- Maven 3.x
- Java 17
- OpenAI API key - Create OpenAI account here, generate OpenAI API key.
├── api-spec/ # API Spec files to be published in your Exchange
├── src/ # Source code directory
├── postman/ # Postman collections + envs for testing
├── mule-artifact.json # Mule runtime and Java versions
└── pom.xml # Maven dependencies
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.
The project uses secure configuration properties for sensitive information. Make sure to configure the following:
-
Create and publish an API Spec based on the files in
api-spec/
- Make sure to match your own org ID and RAML version in
pom.xml
andmac-api.xml
- Make sure to match your own org ID and RAML version in
-
OPENAI_API_KEY
environment variable in your OS (if running locally) -
properties.yaml
file under src/main/resources -
secure-properties.yaml
file under src/main/resources-
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
-
-
Anypoint Platform credentials in your own
.m2/settings.xml
file<servers> <server> <username>your_AP_username</username> <password>your_AP_password</password> <id>anypoint-exchange-v3</id> </server> </servers>
The project includes Postman collections and environments for testing the APIs. You can find them in the postman/
directory.
- 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.