Skip to main content
Trailblazer Community가 Slack에서 시작되었습니다! 더 빠르게 답변을 얻고, 다른 Trailblazer와 소통하며, 전문가에게 배워 보세요. 커뮤니티 참여하기

Build a Custom Lightning Type for Agentforce

Learning Objectives

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

  • Create an Apex-based Lightning type using existing Apex classes.
  • Assign a custom renderer component to your Lightning type.
  • Configure field mappings between schema and components.
  • Enhance existing agent actions with custom Lightning type output rendering.
  • Test and verify your Lightning type integration.

Scenario

Coral Cloud Resorts has a Check Weather agent action that retrieves weather information for guests. The action works well in the current experience, but the weather information is displayed using default text formatting with no visual indicators.

Agentforce chat showing weather output as a mix of formatted text and raw unlabeled numbers (50, 25, 77, 18, 64.4, Calm, 5)

The Coral Cloud team wants to enhance the guest experience with branded visuals for weather data. After adding a custom Lightning type, the weather data displays as a colorful card with display sections and clear labels.

Agentforce chat showing weather in a branded Coral Cloud card with gradient design, weather icon, large temperature display (77°F), and labeled Wind and Humidity sections.

To accomplish Coral Cloud’s request, you’ll create a custom Lightning type that uses the existing DailyWeatherApex class and add a custom renderer to transform the weather output into a rich, visual experience.

Sign Up for a Custom Playground with Agentforce.

To complete this badge, you need a special limited-time custom playground that contains Agentforce and our sample data.

  1. Select Create Playground, then select Yes, Create Playground.
  2. Your new org is automatically attached to your Trailhead account.
  3. Make note of your org’s expiration date and complete this badge before then.
  4. Select Launch to open the playground.

Create the Apex-Based Lightning Type

You’ll create a Lightning type that uses the existing DailyWeather Apex class, which defines weather data structure.

  1. Click Setup and select Setup.
  2. In the Quick Find box, enter Lightning Types, and then select Lightning Types.
  3. Click New Lightning Type.
  4. Enter these details.
    1. Label: Weather Display Enhanced
    2. API Name: Weather_Display_Enhanced
    3. Description: Apex-based type for displaying Coral Cloud weather with custom branded UI
  5. Click Next.
  6. Select Apex as the schema definition method.
  7. In the Search Apex Class field, start typing DailyWeather, then select it from the dropdown when it appears.
  8. Click Create.

Configure the Custom Renderer Component and Field Mappings

Now configure the renderer to display weather data with custom visuals and map the fields.

  1. Open your Weather Display Enhanced Lightning type if it's not already open.
  2. Select the UI Configuration tab.
  3. Confirm Agentforce (Lightning Experience) is selected in the Channel dropdown.
  4. Select the Renderer tab.
  5. In the Renderer Override section, click Change.
  6. In the Select an Output Component window, select enhancedWeatherWidget from the list.
  7. In the LWC Field Mapping section, verify these component fields are mapped to your Apex class fields. Note: Because the field names in the Apex class match the field names in the LWC component, automatic field mapping should handle all connections. If any field isn’t automatically mapped, you can manually map it in this same window.
    1. minTemperatureC = minTemperatureC
    2. minTemperatureF = minTemperatureF
    3. maxTemperatureC = maxTemperatureC
    4. maxTemperatureF = maxTemperatureF
    5. condition = condition
    6. windSpeed = windSpeed
    7. windDirection = windDirection
    8. humidity = humidity
  8. Click Done.
  9. Click Save.

Confirm that the Renderer Override section now shows enhancedWeatherWidget as the selected component, and that all eight fields were properly mapped with no warnings.

Enhance the Check Weather Agent Action Output

Now integrate your custom Lightning type into the Check Weather action through Agentforce Builder.

  1. From the App Launcher , search for and select Agentforce Studio .
  2. In the agents list, click Agent Customization.
  3. Click New Version.
  4. Under Subagents, select Answer Weather Questions.
  5. Select the Check Weather action.
  6. Switch to Script mode using the toggle at the top of the canvas.
  7. Locate the advancedWeatherDetails output parameter.
  8. Replace the existing value of the complex_data_type_name property with c__Weather_Display_Enhanced. Custom Lightning types use the c__ namespace prefix.
  9. Click Save.
  10. Click Commit Version.
  11. Click Commit.
  12. Click Activate.
  13. Click Activate again.

Confirm the complex_data_type_name property shows c__Weather_Display_Enhanced. This ensures your custom renderer with branded visuals will display weather data.

Test Your Enhanced Weather Display

Time to see your custom Lightning type in action! You’re already in Agentforce Builder from the previous steps.

  1. Still in Agentforce Builder, click Preview to enter Live Test Mode.
  2. In the Describe your task or ask a question box, enter Check the weather today.
  3. Observe how the weather information displays using your custom renderer with visual indicators.

Verify the following.

  • Weather data displays with your custom branded UI.
  • Temperature ranges show with visual indicators.
  • The display is more engaging than plain text.

Congratulations! You’ve successfully built an Apex-based Lightning type, configured custom UI components, and integrated it with an Agentforce Employee agent in Lightning Experience. You’re now ready to create custom UI experiences across Salesforce using Lightning types.

Resources

Salesforce 도움말에서 Trailhead 피드백을 공유하세요.

Trailhead에 관한 여러분의 의견에 귀 기울이겠습니다. 이제 Salesforce 도움말 사이트에서 언제든지 새로운 피드백 양식을 작성할 수 있습니다.

자세히 알아보기 의견 공유하기