Newer Version Available

This content describes an older version of this product. View Latest

Get Settings from the Embedded Service Code Snippet

Get settings for use with your Embedded Service Aura components. You can get the Chat button ID or deployment ID assigned to your Embedded Service deployment and the agent and chatbot avatar image URLs.

Use the Aura method getLiveAgentSettings() to grab the settings that you want to use: liveAgentButtonId, liveAgentDeploymentId, chatbotAvatarImgURL, avatarImgURL.

This example shows you how to use the lightningsnapin:settingsAPI component with a custom pre-chat component. The pre-chat component uses different fields and a CSS class when a specific Chat button is used with the chat window.

This example isn’t of a complete pre-chat component. We’ve marked where the rest of your code should go in the code comments.

Important

Before you start, make sure that you have an Embedded Service deployment already set up. You should also have a working Embedded Service Aura component before you make any changes based on the Embedded Service deployment settings.

To get started, go to the Developer Console and open one of your Embedded Service Aura components.

  1. Add a line in your component markup file to create the settings API component.
  2. In your init handler, use the Aura method getLiveAgentSettings() to grab the settings you want.
    This example customizes the First Name and Last Name fields when a certain Chat button is used by the current chat window by:
    • Pre-populating the visitor's name as "Anonymous Visitor"
    • Making the fields read-only
    • Adding a CSS class called anonymousField
  3. In your component CSS file, add a CSS rule for our new anonymousField CSS class.
  4. Save your component.