Loading
Salesforce now sends email only from verified domains. Read More
Help Agent Performance DegradationRead More
Agentforce Contact Center
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create a Form Based on an Apex Class

          Create a Form Based on an Apex Class

          Apex-based forms offer more flexibility than global action-based forms, enabling you to create both static and dynamic WhatsApp messages. To create an Apex-based form, create the Apex class, and then link it to a form messaging component. When the messaging end user submits their responses to the form, Salesforce executes the Apex, sending the data to Salesforce. You must configure how to save that data.

          Required Editions

          View supported editions.
          Checkmark This article applies to: Enhanced WhatsApp channels
          X icon This article doesn’t apply to: Enhanced In-App Chat, Enhanced Web Chat v1, Enhanced Web Chat v2, Standard and Enhanced Facebook Messenger, Standard and Enhanced SMS, Enhanced Apple Messages for Business, Enhanced LINE, and Bring Your Own Channel
          User Permissions Needed
          To create messaging components:

          Customize Application AND View Setup and Configuration

          OR

          System Administrator

          To send and receive messages in Messaging: Messaging Agent

          Create the Apex Class

          1. From Setup, in the Quick Find box, enter Apex Classes, then select Apex Classes and click New.
          2. In the class editor, enter this class definition.
          3. Click Save.

          Create the Form Messaging Component

          1. Go to the Messaging Components page in Setup.
          2. Click New Component.
          3. Select the Form messaging component and click Next.
          4. Select Apex Class and click Next.
          5. Enter the form title, select the Apex class that you just created, and then click Next. The title appears in the messaging session as a link to the form.
            Messaging Component setup flow with Form Title and Apex Class fields filled out.
          6. Enter a name and description of your component. Messaging end users can’t see this information. But, it helps service reps quickly identify the component’s purpose when choosing a message to send from the Service Console.
          7. Click Done. The Messaging Component Builder opens.

          Add the Flow Format to the Apex Form Messaging Component

          To create a WhatsApp Flow, add a Flow format to the form messaging component. Configure the message content in the flow.

          1. Open the Apex-based form messaging component. To create an Apex-based form messaging component, see Create and Send Secure Forms in Messaging Sessions.
          2. In the Component Formats section, click Details, and then click Add Format.
          3. Select Flow, and then click Done. The format controls how the component looks in messaging sessions. Each messaging component is available in one or more formats, and some formats work only in certain channels. For a list of formats that each channel supports, see Messaging Component Types and Formats. It’s a good idea to add at least one supported format for each channel where the component will be sent. If no formats are added, the component uses the default text format.
          4. In the left-hand sidebar, under Component Formats, click Flow.
            The Flow layout selected in the Messaging Component Builder.
          5. In the Initial Message section, enter the message that appears when a conversation starts with the customer.
          6. In the Launch Button section, enter a name for the button that launches this WhatsApp Flow.
            Messaging Component Builder canvas showing a preview of the Initial Message and Launch Button text.
          7. To add a screen, click Add Screen. You can add multiple screens to the Flow.
          8. Enter a title for the screen.
          9. To add content to the screen, click Add Content.
          10. Expand one or more content type boxes and then select one or more screen elements. For example, expand the Media and Selection boxes and then select Image and Multi-Select Question. To show content and control screen navigation using conditional logic, under the Conditional Logic box, select a Switch or If screen element.
            The Add Content screen from the Messaging Component Builder.
          11. To add the selected screen elements to the screen, click Done. Each screen can have only one footer with a button. Each button either navigates to a subsequent screen in the flow or completes the flow. A button can’t navigate to a former screen. For example, screen 2 can’t navigate back to screen 1.
          12. In the Component Properties, configure each screen element.
            Screen element configuration options in the Component Properties panel.
          13. The canvas shows a preview of the screen that is currently expanded.
            Messaging Component Builder canvas showing how the Flow Screen Title Text and the Dropdown Selection Text populate.
          14. To create a second screen, click Add Screen again.
          15. Enter the details for the second screen.
          16. If this screen is the last screen in the Flow, add a Footer with a Complete footer action, which completes the Flow.
          17. Expand the Screen 1 section, select the Footer content type, and configure the footer action to navigate to the next screen.
            Messaging Component Builder canvas showing how the Footer Action and Next Screen settings appear.
          18. After you update the Flow format properties, save the messaging component.
          19. In the left-hand sidebar, under Component Formats, click the Text format type to update its properties. The plain text version is sent if your preferred format isn’t available or doesn’t load. While global action-based and Apex class-based forms can’t be sent in plain text, you can edit your component’s plain text version so it contains a link to a public form or shows a text-only list of the questions that appear in your form.
            Messaging Component Builder with the Text component format layout shown.
          20. When you’re done editing your component, click Save. Your component is saved in a draft state.
          21. To make this messaging component available to service reps, click Activate.
          22. To take the component offline—for example, to give you time to reconfigure it—open it in the Messaging Component Builder and click Deactivate. When you're ready, activate it again.
           
          Loading
          Salesforce Help | Article