A comprehensive Dify plugin that enables seamless integration with Salesforce, providing powerful data access and interaction capabilities for your AI workflows.
- Author: eric-2369
- Version: 0.0.1
- Type: tool
- Secure Authentication: Robust authentication with automatic credential management
- Smart Session Management: Intelligent session handling with automatic token storage and refresh
- Auto Recovery: Automatic error handling and session recovery for uninterrupted workflows
- Comprehensive Logging: Full logging integration with Dify's plugin logging system
- Multi-language Support: English, Chinese, and Portuguese interface support
- High Performance: Optimized for efficient Salesforce data operations
- Install the plugin in your Dify environment
- Configure your Salesforce credentials in the plugin settings
-
Salesforce Login URL
- Production:
https://login.salesforce.com - Sandbox:
https://test.salesforce.com
- Production:
-
Salesforce Username
- Your Salesforce account username
-
Salesforce Password + Security Token
- Your password concatenated with your security token (no space between them)
- Example: If password is
mypasswordand token isABC123, entermypasswordABC123
- Log in to Salesforce
- Go to Setup → My Personal Information → Reset My Security Token
- Click "Reset Security Token"
- Check your email for the new security token
Retrieve account information:
SELECT Id, Name
FROM Account LIMIT 10Query contacts with specific criteria:
SELECT Id, Email
FROM Contact
WHERE Name = 'John Doe'Access related data across objects:
SELECT Id, Channel_Type__c
FROM Holistic_Engagement__c
WHERE Person__r.Contact__r.Name = 'John Doe' LIMIT 10The plugin returns results in the following JSON format:
{
"totalSize": 5,
"done": true,
"records": [
{
"attributes": {
"type": "Account",
"url": "/services/data/v63.0/sobjects/Account/001..."
},
"Id": "001...",
"Name": "Sample Account"
}
],
"query": "SELECT Id, Name FROM Account LIMIT 10"
}- Secure Authentication: Robust authentication with Salesforce
- Token Storage: Persistent session storage using Dify's KV storage
- Automatic Refresh: Intelligent token lifecycle management
- Error Recovery: Automatic error handling and session recovery
- Secure Credential Storage: All credentials are securely stored in Dify
- Session Management: Proactive session management and renewal
- Error Handling: Comprehensive error handling with user-friendly messages
- Session Caching: Efficient session reuse to minimize overhead
- Optimized Requests: High-performance API communication
- Memory Management: Efficient resource usage in serverless environment
The plugin provides comprehensive error handling for common scenarios:
- Invalid Credentials: Clear messages for authentication failures
- Network Issues: Timeout and connection error handling
- Query Syntax Errors: Detailed error messages for invalid queries
- API Limits: Proper handling of Salesforce API limits
- Session Expiry: Automatic session refresh and retry
The plugin uses Dify's logging system to record:
- Authentication attempts and results
- Data query executions
- Session refresh operations
- Error conditions and resolutions
-
Authentication Failed
- Verify your username and password
- Ensure security token is current and correctly concatenated
- Check if your Salesforce org allows API access
-
Invalid Query
- Verify query syntax is correct
- Ensure you have permission to access the queried objects
- Check field names and object names are correct
-
Network Timeouts
- Check your network connection
- Verify the Salesforce login URL is correct
- Ensure firewall allows outbound HTTPS connections
salesforce-dify-plugin/
├── manifest.yaml # Plugin configuration
├── requirements.txt # Python dependencies
├── provider/
│ ├── salesforce.yaml # Provider configuration
│ └── salesforce.py # Credential validation
├── tools/
│ ├── soql_query.yaml # Tool configuration
│ └── soql_query.py # SOQL query implementation
└── utils/
└── session_manager.py # Session management logic
- SalesforceSessionManager: Handles authentication and session management
- SalesforceProvider: Validates credentials during plugin configuration
- SoqlQueryTool: Executes data queries with automatic error handling
This project is licensed under the terms specified in the LICENSE file.
For issues and questions:
- Check the troubleshooting section above
- Review Salesforce API documentation
- Contact the plugin author