APIs are the backbone of seamless communication and data exchange between diverse software applications. But creating and maintaining comprehensive API documentation in MuleSoft Anypoint Exchange can be a time-consuming and labor-intensive task for developers. This is where Agentforce can revolutionize the process by automating the generation of API documentation.
Agentforce overview
Agentforce is the next-gen digital labor platform from Salesforce that has everything essential to make AI agents real and reliable for business and information technology needs. Agentforce agents collaborate with humans to achieve success across sales, service, marketing, and commerce. These agents include Agentforce for Service and Agentforce for Sales. We will be deploying Agentforce for Service Agent (ASA) to automate generation of API documentation.
API documentation
Clear API documentation is essential for easy discovery and reuse. However, we discovered that between 50–75% of our applications lacked this crucial documentation. This created a major obstacle for both product and engineering teams, as there was little to no information available to help them understand the API’s functionality.
Adding to the complexity, our APIs follow a specific naming structure that doesn’t clearly convey the underlying business capability. Without documentation and with complex technical names, it was difficult for anyone to grasp the API’s purpose. Agentforce manages the demanding task of generating AI-powered API documentation using API specification and digital labor.
Why use Agentforce for API documentation
Agentforce-based API document generation saves time, improves accuracy, ensures consistency, and provides scalability.
- Increased efficiency: Agentforce-powered tools can analyze APIs in Anypoint Exchange, extract relevant information, and generate detailed API documentation in a fraction of the time it would take a developer, allowing developers to focus on more complex and innovative work.
- Data-driven responses: By using Agentforce, the risk of human error in documenting APIs is avoided, resulting in more accurate and reliable documentation generated using OAS (Open API Specification). Users can validate generated documents and contribute additional information.
- Consistency: Agentforce ensures that the formatting and structure of the API documentation remain consistent across different APIs, improving readability and usability for developers.
- Scalability: As the number of APIs and software projects grows, agents can easily scale to handle the increasing workload of generating and updating documentation
- Learning and adaptation: Agentforce can learn and adapt as it works using better data retrieval.
- Improved customer satisfaction: Agentforce can provide quick, accurate responses and personalized experiences.
How does Salesforce use Salesforce for API documentation?
Salesforce’s Business Technology organization developed a smart “Salesforce on Salesforce” approach to streamline the API documentation process. By leveraging tools like Agentforce for Service Agent (ASA), Anypoint Exchange, Anypoint CloudHub, and the Anypoint API Experience Hub (AEH), this solution establishes a seamless approach to API management, serving as a source of inspiration for effective practices.
Anypoint API Experience Hub (AEH)
The Anypoint Experience Hub (AEH) is a platform for creating and managing personalized API portals for thriving API ecosystems and for growing engagement for API products. AEH plays a key role by simplifying API discovery and documentation, ensuring that Agentforce can easily access and share up-to-date API details, enhancing efficiency and collaboration across teams. Anypoint API Experience Hub is powered by Salesforce Experience Cloud which eases hosting of Agentforce Service Agent via Messaging for In-App and Web (MIAW) of the Salesforce Platform.
Agentforce Service Agent (ASA)
Agentforce Service Agent (ASA) is a proactive, autonomous application that provides specialized, always-on support to employees or customers or developers. ASA is equipped with the necessary business knowledge to execute tasks according to their specific role. Use of ASA for API document generation helps developers write documents on the go with the use of MuleSoft API-led connectivity.
Anypoint CloudHub
Anypoint CloudHub 2.0 is a fully managed, containerized integration platform as a service (iPaaS). CloudHub supports building and deploying APIs using an API-led connectivity approach.
Anypoint Exchange
Anypoint Exchange is a catalog or market place of all reusable, pre-built assets like API specifications, fragments, connectors, and custom components. Anypoint Exchange provides its functionalities as Rest APIs to list assets, fetch API specification as OpenAPI Specification (OAS), and publish documentation, to name a few.
API-led solution
API-led connectivity is MuleSoft’s methodical way to connect data to applications through reusable and purposeful APIs within an organisation’s ecosystem. The APIs used in an API-led approach to connectivity fall into three categories: experience, process, and system layers.
System layer
APIs in this layer usually access the core systems of record and provide a means of insulating the user from the complexity or any changes to the underlying systems. Once built, many users can access data without any need to learn the underlying systems and can reuse these APIs in multiple projects.
- Exchange System API: expose Anypoint Exchange functions – fetch API specifications and publish API documentation as API
- LLM System API: connects to LLMs via Einstein LLM Gateway, this API accepts prompts and responds with responses from LLM. LLM Gateway will have the option to use one of the many models available like OpenAI_GPT4_16k, OpenAI_GPT4_32k, OpenAI_GPT4_Turbo, OpenAI_GPT3_16k. Based on document needs and prompt tuning/engineering so the best model can be chosen. The use of Einstein LLM API is optional, instead MuleSoft AI Chain connector can be used for the same prompts that can also be executed within Agentforce Service Agent, all via Prompt Template Agent Action.
Process layer
APIs in this layer interact and orchestrate with and shape data within a single system or across systems (breaking down data silos). They help implement an organisation’s processes without having to worry about the source systems where data originates or the target channels through which that data is delivered. They lend themselves very well to automation capabilities and Bots.
- Document Generator Process API: This API orchestrates Exchange System API and LLM System API. Process API fetch API specifications as OAS using an Exchange System API and create prompts to be sent to LLM System API to generate API documentation
Sample prompt:
“Using the API Specification Snippet given in the prompt, generate an API documentation in json format containing these keys {‘shortDescription’ : ‘Give a short description of below api in 2 lines. Don’t use keyword swagger in response’ ,’summary’: ‘A 10 lines summary of the snippet for a non technical user like managers, Business owners. Don’t use keyword swagger in response’,’securityProtocols’ : ‘Describe the security scheme for the below api in 2 lines’,’resourceEndpoints’ : ‘A JSON array containing objects with keys {‘EndPoint’, ‘Method’ and ‘Description’} Explaining non Technical users what that endpoint can be used for. create separate objects for each Endpoint-method combination.’}” |
Experience layer
APIs are catered toward delivering a delightful end-consumer experience. They get their power by mainly focusing on the consumer and reusing the building blocks already created (typically in the form of System or Process APIs). Often built by a different persona, they can speed up delivery by working from the API specs built as a part of the design-first approach.
- Document Generator Experience API exposes above Process API to Agentforce Service Agent (ASA). ASA calls this “Experience API as Salesforce Flow – Agent Action” during the agent interaction.
Using Salesforce Flow, create flows to expose Experience API methods as Autolaunched Flow. Here is a sample flow used to publish generated document to Anypoint Exchange using an experience API:
Within Agent builder, create flow-based agent actions like:
- Get API Details
- Generate API documentation for a given API
- Publish API documentation to Exchange for a given API
Using Salesforce Flows created above, orchestrate agent actions with topics in Agent Builder, and include an off_topic handler for managing errors or unknown cases. As outlined in this list of best practices, provide the necessary scope and instructions for ASA to function effectively.
Document generation agent
Our document generation agent is now set up, allowing consumers and developers to interact with this agent from the Anypoint API Experience Hub. They can create or modify documentation for the APIs in real time using Agentforce.
The team can ensure that documentation is regularly updated and maintained to adapt to changes in APIs. This process can be automated by integrating it with the Continuous Integration and Continuous Deployment (CI/CD) pipeline.
Streamlined processes for better accuracy
Using Agentforce for API documentation streamlines the process, enhances data accuracy and consistency, and improves the developer experience within the Anypoint API Experience Hub. By leveraging Agentforce – digital labor, developers can focus on building innovative software solutions rather than manual documentation tasks.
With the release of Agentforce 2.0, additional integration capabilities such as MuleSoft for Flow: Integration, MuleSoft for Agentforce: API Catalog, and MuleSoft for Agentforce: Topic Center simplify extending Agentforce capabilities within the solution. Want to see this solution in action or to learn more about Agentforce and MuleSoft? Attend an Agentforce World Tour near you, and don’t forget to head over to MuleSoft.com to learn about everything MuleSoft for Agentforce!
Editor’s note: This article was collaboratively written by Gopalakrishnan TV, Bharath Kumar NJ, and Nirbhay Sharma.