Skip to main content

Seamlessly Interact with Dev Assistant as You Code

Learning Objectives

After completing this unit, you’ll be able to:

  • Access Dev Assistant.
  • Explain how Dev Assistant can help you write code.
  • Explain what you can do with slash commands.
  • Use the Command Palette to generate Apex Code in context.

Get to Know Your Dev Assistant

Dev Assistant is like having a coding buddy by your side who’s always ready to help you with Apex and LWC code. It offers an interactive, conversational approach to Apex and LWC coding, making Salesforce development a whole lot easier and way more fun! Just put your questions or slash commands in chat to ask Dev Assistant for help.

To get to the chat screen, click the Einstein icon in the Activity Bar. Once you’re in, Agentforce knows what you’re working on and keeps up with the conversation. It even suggests code based on what you write and the file you’re working on in your VS Code editor. If you need more help, just continue chatting with Dev Agent to get an even better response.

VS Code window with the Einstein icon highlighted in the Activity bar

Try These Sample Conversation Starters

Here’s a handy list of prompts to help you start chatting with Dev Assistant.

  • Ask questions about your Salesforce project: “How do I expose my Apex method to a Lightning web component?”
  • Generate a test for a given Apex method: “/test Generate a test for the getSimilarProducts() method”.
  • “Write an Apex method that accepts product name as input and retrieves order items filtered on product name”.
  • “Write an Apex method that accepts a list of SObjects and a field name and returns a set of non–null field values”.

Then you can continue the conversation. For example, let’s say you ask Dev Assistant: “Create a Lightning web component that uses the lightning-input attribute”.

Once you receive a response, follow up with something like this to continue programming together: “In fact, I'd like to add a rich text input area to my LWC.”

Use Slash Commands

You probably noticed the slash command in the bullet list. Slash commands make it easy to start a conversation. They’re like ready-made prompt templates. Use them as-is or add details to get more specific responses. ‌Type / to access them. After you get a response, keep chatting to increase the response accuracy. Here’s a list of currently available commands. Happy chatting!

Slash command

Description

/explain

Explain the code in the open tab, or paste the code you want the dev assistant to explain, in the chat window..

/test

Generate a test case.

/document

Generate documentation for the given code block in the default documentation scheme for the current file's programming language.

Generate Apex Code Right in Your Editor

You can quickly generate boilerplate code from inside an Apex file in the VS Code editor. In an existing Apex file, place your cursor on the line in the file where you want the suggested code generation to be placed. Then from the Command Palette, run Einstein: Generate Code command. Enter a description of the code that you want to generate in the query. For example, “Write a method that takes an account as a parameter and returns all contacts associated with that account.” Agentforce generates code for you, exactly where you need it!

Resources

Salesforce ヘルプで Trailhead のフィードバックを共有してください。

Trailhead についての感想をお聞かせください。[Salesforce ヘルプ] サイトから新しいフィードバックフォームにいつでもアクセスできるようになりました。

詳細はこちら フィードバックの共有に進む