Free computer code on screen

Einstein for Developers Open Beta Is Now Available

Salesforce’s generative AI solution, Einstein for Developers, is now in its Open Beta phase, offering enhanced developer productivity.

Generative AI stands as a revolutionary technology that boosts developer efficiency, speeds up software application development, and dismantles the obstacles for anyone seeking to delve into programming. Earlier this year at TrailblazerDX, we introduced Einstein for Developers, and now, Salesforce’s generative AI solution that supercharges developer productivity is officially available in Open Beta.

Tailored specifically for Salesforce languages and frameworks, Einstein for Developers possesses the ability to generate Apex code through natural language. Lightning Web Components (LWC) support is on the horizon. In this blog post, we’ll embark on a journey to understand how to commence your Einstein for Apex development and explore how it has the potential to redefine your development process.

Einstein for Developers vs. Alternative AI Coding Tools

The current generative AI coding tools are primarily trained on widely used programming languages like Java, Python, and others, along with publicly accessible code. This presents a challenge when it comes to Salesforce-specific languages like Apex and Lightning Web Components (LWC) since they are proprietary. Consequently, these tools often lack the training necessary to offer precise recommendations in the context of Salesforce development.

Moreover, the effectiveness of AI coding tools heavily relies on the context provided to them. Public coding tools lack the specific Salesforce context of your organization, including metadata, making recommendations less reliable and potentially inadequate for your requirements. Utilizing publicly available AI tools may expose your private code beyond the Salesforce trust boundary, potentially creating a security vulnerability.

With Einstein for Developers, we’ve harnessed CodeGen, our own open-source model for program synthesis. We host CodeGen within the Salesforce trust boundary and have specifically trained it on Salesforce-specific languages like Apex and LWC. Through dynamic grounding integrated into the code generation process, Einstein enhances its recommendations by utilizing your metadata and code. Our AI trust layer within Einstein guarantees that your data and code remain securely contained within Salesforce and are never stored externally.

Getting Started with Einstein for Developers

Einstein for Developers is presently available in open beta. To activate Einstein for Developers within your organization, follow these steps: Go to Setup, then navigate to Einstein for Developers, toggle the enable switch, and accept the terms and conditions.

Once you’ve enabled Einstein for Developers, the next step is to install the Einstein for Developers Visual Studio Code extension on your VS Code Desktop. Additionally, Einstein will be accessible in Code Builder, our web-based Integrated Development Environment (IDE), which is expected to be widely available in October. Keep an eye out for further updates!

To make effective use of the Einstein for Developers tool, follow these steps:

  1. Open your Visual Studio Code, then navigate to File > Open Folder in the menu. You can either open an existing Salesforce DX project or set up a new project.
  2. To collaborate with Einstein for Developers, execute the “SFDX: Authorize an Org” command to establish a connection with a Salesforce sandbox org or scratch org. This is the environment in which you’ll be utilizing Einstein for Developers.
  3. If you’re using scratch orgs, enable Einstein for Developers by activating the add-on scratch org feature. You can do this by modifying and saving the config/project-scratch-def.json file in your Salesforce DX project and adding the “EinsteinGPTForDevelopers” feature to your existing feature list.

For instance:

  "orgName": "Acme Company",
  "edition": "Developer",
  "features":[“Communities”, “ServiceCloud”, "EinsteinGPTForDevelopers"]

Lastly, you can commence the process of generating Apex code by formulating a prompt through one of the following methods:

  1. Utilizing the Einstein Sidebar accessible from the Activity bar, as illustrated below:

Another approach is to employ the Command Palette command by selecting “SFDX: Generate Code with Einstein” (as depicted in the screenshot below). It’s important to note that you must be working within an Apex file (.cls) for this command to become available.

Here’s an example of a prompt:

“I would like to generate an Apex class named ‘OpportunityQuerySelector.’ Inside this class, create a method named ‘getSumOfOpportunityRecords’ that fetches the count of opportunity records associated with a particular Account record. The method should take ‘accountId’ as a parameter. It’s essential to adhere to security best practices and ensure that the code operates in user mode.

Subsequently, the generated output is presented below.

public with sharing class OpportunityQuerySelector {
    public static Double getSumOfOpportunityRecords(Id accountId) {
        List groupedResults = [
            SELECT SUM(Amount) total
            FROM Opportunity
            WHERE AccountId = :accountId
            WITH USER_MODE
        return (Double) groupedResults[0].get('total');

Although the generated code provided above may not necessitate many modifications, it’s important to acknowledge that you might have to tailor the output generated by Einstein to suit your specific development requirements. The Einstein: History and Feedback panel within the Integrated Development Environment (IDE) enables you to provide feedback regarding the generated output. This feedback is of utmost significance in enhancing our Language Model Model (LLM) and enhancing the generated results. We eagerly await your feedback and insights.

Reforming the Development Process

Our journey with generative AI to revolutionize your development workflow has just begun. Take a look at what’s on the horizon:

  • Lightning Web Component (LWC) support: Generate LWC code based on natural language processing (NLP)
  • Predictive in-line code completion: Automatically fill in the next line of code that’s suggested with contextual project metadata
  • Code performance check: Scan Apex code and fix runtime errors during the development process
  • Conversational assistance: Ask Einstein to generate contextual code and documentation, explain code, or solve complex problems

In Conclusion

As Einstein for Developers expands its capabilities to support LWC, provide intelligent code completion, and deliver conversational assistance, you will be able to build on the Salesforce Platform faster than ever before.

Try the beta today and join us at Dreamforce ’23 to dive deeper into Einstein for Developers!