Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

ProcessFormHandler Interface

Apex interface that processes the responses to forms submitted in a messaging session.

Namespace

RichMessaging

ProcessFormHandler Methods

The following are methods for ProcessFormHandler.

processFormRequest

Processes the form request and returns the ID of the record created during form processing.

Signature

ID processFormRequest(RichMessaging.ProcessFormResponse formResponse)

Parameters

  • formResponse: Type: RichMessaging.ProcessFormResponse The form response.

Return Value

  • ID: Type: RichMessaging.ProcessFormResponse

ProcessFormHandler Example Implementation

The sample ContactApexFormHandler Apex class automatically captures the customer's submitted details, creates a Contact record in Salesforce, and returns the Contact record ID.

This is an example implementation of the RichMessaging.ProcessFormHandler interface.

1global class ContactApexFormHandler implements Richmessaging.ProcessFormHandler{
2    global ID 
3    processFormRequest(RichMessaging.ProcessFormResponse formResponse) {
4        // Create a new Contact object
5            Contact newContact = new Contact(
6            Phone = formResponse.formValues.get('Phone'),
7            Salutation = formResponse.formValues.get('Salutation'),
8            Email = formResponse.formValues.get('Email')
9            );
10    // Insert the new contact into the database
11    insert newContact;
12     // Return the ID of the newly created contact
13     return newContact.Id;

For more information, see "Create a Form Based on an Apex Class" in this help topic.