
Before anything else, a quick disclaimer — I do a lot of work on Salesforce so my opinions on Agentforce may be biased.
I’ve closely followed Google’s announcement on Agent Development Kit and A2A protocol for the last few weeks. I’ve also presented sessions on ADK, A2A and AI agents at Google community events such as this one.
Two powerful platforms, Google’s Agent Development Kit (ADK) and Salesforce’s Agentforce, are empowering us to build intelligent, conversational experiences. But what if we could bring them together?
In this post, I experimented with how you can integrate Google ADK with Salesforce. I’ll walk you through the process of building a simple but powerful AI agent that can query your Salesforce data using natural language.
Imagine asking your CRM: “Show me all the open opportunities in New York.” With this integration, that’s not just a dream — it’s a reality you can build today.
Google’s ADK excels at creating sophisticated, goal-oriented AI agents that can understand and respond to human language. Salesforce, the world’s leading CRM, is the central hub for customer data. By combining them, you can:
- Create Natural Language Interfaces for your CRM: Allow your sales and service teams to interact with Salesforce in a more intuitive, conversational way.
- Automate Repetitive Tasks: Build agents that can create leads, update records, or log activities based on simple voice or text commands.
- Build Custom AI Assistants: Develop specialized agents that can provide real-time insights and support to your team, directly within their workflow.
Before we dive in, make sure you have the following:
- A Google Cloud Platform (GCP) Account: To use the Agent Development Kit.
- A Salesforce Developer Edition Org: With Agentforce enabled.
- Python 3.8+: Installed on your local machine.
- Visual Studio Code (or your preferred code editor): For writing our Python script.
First, we need to configure Salesforce to allow our external agent to connect securely.
- Enable Agentforce: If you haven’t already, follow the Salesforce documentation to enable Agentforce in your Developer Edition org.
- Create a Connected App: This will give our agent API access to Salesforce.
- In Salesforce Setup, search for “App Manager” and click “New Connected App.”
- Fill in the basic information (App Name, Contact Email).
- Under “API (Enable OAuth Settings),” check “Enable OAuth Settings.”
- Provide a Callback URL (e.g.,
http://localhost:8080/callback
). - Select the following OAuth Scopes:
api
refresh_token, offline_access
- Save your Connected App.
- Get your Consumer Key and Secret: After saving, you’ll be taken to the app’s management page. Click “Manage Consumer Details” to get your Consumer Key and Consumer Secret. Keep these safe!
Now, let’s create a basic ADK agent in Python. This agent will be responsible for taking user input and interacting with our Salesforce integration code.
For this example, we’ll keep the ADK agent simple. The core logic will be in our Salesforce connection script.
This is where the magic happens. We’ll write a Python script to handle the OAuth 2.0 authentication flow with Salesforce and query data.
We’ll use the popular requests
library to make HTTP requests to the Salesforce REST API. If you don’t have it installed, open your terminal and run:
pip install requests
Our Python script will have two main functions:
get_salesforce_access_token
: This function will take your Consumer Key, Consumer Secret, username, and password to get an access token from Salesforce.query_salesforce
: This function will use the access token to make a SOQL (Salesforce Object Query Language) query to the Salesforce API.
Now, we’ll combine our ADK agent with our Salesforce connection script. The ADK agent will capture the user’s request, and our script will query Salesforce and return the results.
For example, a user might say, “Find all contacts with the last name ‘Smith’.” Our ADK agent will extract “Smith” and pass it to our query_salesforce
function, which will then execute the following SOQL query:
SELECT Name, Email, Phone FROM Contact WHERE LastName = 'Smith'
The results will be returned to the user through the ADK agent.
I’ve published the complete, working code for this project on Colab. You can find it here:
https://colab.research.google.com/drive/1DFvsMnI8Sp4vhwQxC0jEYhw_23pQtmWk?usp=sharing
I’ve also included some instructions on how to set up and run the project.
We’ve just scratched the surface of what’s possible when you connect Google’s ADK with Salesforce. You’ve learned how to build a bridge between these two powerful platforms, opening up a world of possibilities for creating intelligent, conversational experiences.
From here, you can explore more advanced integrations, such as:
- Creating and updating records: Build agents that can create new leads, update opportunities, or log customer interactions.
- Integrating with other systems: Connect your agent to other tools and services to create even more powerful workflows.
- Adding more sophisticated AI: Use Google’s advanced AI models to add features like sentiment analysis and intent recognition to your agent.
The future of business is intelligent and conversational. By combining the power of Google’s ADK and Salesforce, you can be at the forefront of this transformation. Happy coding!
Source Credit: https://medium.com/google-cloud/my-ai-agent-experiments-connecting-salesforce-agentforce-with-google-clouds-adk-8dd8a56d5827?source=rss—-e52cf94d98af—4