Skip to content

SFDC-Assets/FormBuilder

Form Builder

This project provides a component that will convert PDF documents into Discovery Framework Omniscripts

What's included in the Project

  • Apex - AgentCreatorMetadataService - Extension of Metadata Service to create Omnistudio metadata
  • Apex - AgentForceExtractPDFPrompt - Reads the response of a Prompt template and returns it to an Omniscript for processing
  • Apex - AgentforceOmniscriptCreator - Called as a Remote action from the FormBuilder Omniscript to create the Discovery Framework Omniscript
  • Flexipage - AgentforceOmniscriptCreator - Lightning App Page with the FormBuilder Omniscript added
  • genAIPromptTemplate - ProcessPDF - Prompt template that reads an uploaded PDF file and extracts the text and formats it as questions for an Omniscript
  • OmniDataTransform - FormBuilderGetOmniscriptId - Gets the Omniscript Id after creation
  • OmniDataTransform - FormBuilderGetUniqueSteps - Gets the unique steps defined in the FormBuilder
  • OmniDataTransform - FormBuilderMakeUniqueStepsArray - Utility data mapper that creates an array of steps for the Omniscript that is to be created
  • OmniDataTransform - FormBuilderTransformPromptIntoOmniscript - Data mapper that reads the results of the Prompt template and formats
  • Omniscript - Form/Builder/English - Omniscript that drives the form builder process
  • Permission Set - gps_Form_Builder - Permission Set that grants access to the Apex classes and tab used by the component
  • Tab - gps_Form_Builder - Custom tab that shows the AGentforceOmniscriptCreator flexipage

Prerequisites for the Org

  • Prompt Templates must be enabled in the Org
    • The user executing the Form Builder must have at least the Prompt Template User permission set license
  • Licenses for Omnistudio must be in the Org
    • The user executing the Form Builder must have at least an Omnistudio User permission set license
  • Discovery Framework must be enabled in the Org and the Import/Export option for Discovery Framework must be enabled

Steps to install this in an Org

  • Ensure that all prerequisites are in place

  • Download the contents of the force-app folder

  • Deploy the components at the same time. Note that there are dependencies and it's easier to deploy them all together.

    • You can also use the following command line in terminal replacing: ALIASORLOGIN with your Org's Alias or login: sf project deploy start --source-dir force-app/main/default--target-org ALIASORLOGIN
  • Assign the GPS Form Builder Permission Set to the user that will execute the Form Builder

  • Create a Connected App and Named Credential using these steps:

  1. Create a Connected App
    1. Go to Setup → External Client Apps → Settings
    2. Ensure that the Allow creation of connected toggle is enabled and Click the New Connected App button
    3. Set the following values:
      1. Name: ConnectAPI
      2. API Name: ConnectAPI
      3. Contact Email: Your email address
      4. Click the Enable OAuth Settings checkbox
      5. Callback URL: https://login.salesforce.com (Note we will come back and change this value)
      6. Auth Scopes
        1. Select
          1. Full access (full)
          2. Perform requests at any time (refresh token, offline access)
      7. Click the Enable Client Credentials Flow
        1. Click Ok on the popup window
      8. Click Save and then click Continue
      9. Click the Manage Consumer Detail button
        1. Verify your identity through you email if required
        2. Keep the screen with the Consumer Key and Consumer Secret open
  2. Create an Auth Provider
    1. Go to Setup → Auth. Providers
    2. Click the New button
    3. Select Salesforce as the Provider Type
    4. Enter the following values:
      1. Name: ConnectAPI
      2. URL Suffix: ConnectAPI
      3. Consumer Key: Paste from Step ib above
      4. Consumer Secret: Paste from Step ib above
      5. Default Scopes: refresh_token full
      6. Click Save
      7. At the bottom of the screen find the Callback URL value and copy this value
  3. Update the Connected App
    1. Go to Setup → App Manager
    2. Find the ConnectAPI Connected app and click the View button on the right hand side of the list
    3. Click the Edit button
    4. Paste in the value from Step 2dvii above into the Callback URL field
    5. Click the Save button and then click the Continue button
  4. Wait for 10 minutes to make sure that the Connected App has been updated
  5. Create the Named Credential
    1. Go to Setup → Named Credential
    2. Click the dropdown on the New button and select New Legacy
    3. Set the following values:
      1. Label: ConnectAPI
      2. Name: ConnectAPI
        1. Note you can select a different Name for the Named Credential. If you do then you will need to update the CallExplainerService action of the Get Last Explainer Messages to match the name you select
      3. URL: Your Domain Name followed by my.salesforce.com
        1. Ex: https://storm-2174aa3fc55207.my.salesforce.com
          1. Note: There may be issues if your domain name has .demo. in it. If that’s the case then try adding .demo. before my.salesforce.com
      4. Identity Type: Named Principal
      5. Authentication Protocol: Oauth 2.0
      6. Authentication Provider: ConnectAPI
      7. Click Start Authentication Flow on Save
      8. Click Allow Merge Fields in HTTP Header
      9. Click Allow Merge Fields in HTTP Body
    4. Click the Save button
      1. Note if you receive an error message here, wait a few minutes and delete the Named Credential and try again. Connected Apps can take up to 10 minutes to create
    5. Enter your credentials to the Org
    6. Click the Allow button
    7. Click the Confirm button

How to use the Form Builder

  1. Download the PDF to your computer. See the known limitations below for limitations on the PDF
  2. From the Action Launcher, open Form Builder
  3. Click the Upload PDF file and select the PDF file
  4. Click Next
  • If the PDF is larger than what the prompt template can process, an error message will be returned
  1. Review the Questions that the prompt template has returned
  • The prompt template will make its best guess about what are data capture fields and the data type of the fields. For example, the prompt template may classify a radio button as a set of checkboxes.
  1. Make edits to the Questions as necessary.
    1. These edits might be deleting or manually adding Questions. The data type of the Question can also be changed.
    2. Rules for Questions:
      1. The Question Name field should not have spaces, should start start or end in an underscore and should. not have 2 consecutive underscores in the name
      2. Question Names must be unique within the Omniscript. The prompt template should ensure this is the case but in certain situations there may be duplicates.
      3. Question Text can be up to 1000 characters
      4. All Radio Questions must have a | separated list of possible answers
  2. Determine the step of each Question
    1. By default all Questions will be set to the Step1 step, but you can change this and set the Step for each Question.
    2. Simply enter the name of the Step. The name of the step does not have to contain the word “Step” and can be any value
  3. Enter the Type, Subtype and Language of the Omniscript.
    1. The Type and SubType cannot create spaces and the combined length of the Type, Subtype and Language must not exceed 60. These are the standard rules for creating an Omniscript.
    2. The combination of Type, SubType and Language must be unique in the Org. If there’s an existing Omniscript with the same Type, Subtype and Language you will receive an error.
  4. Click Next
    1. Validations will be performed and any errors will be returned
  5. For this example, click No for creating an Agent more information about that can be seen below
  6. Click Next
  7. To see the created Omniscript, click the appropriate link based on the type of designer you are using.
    1. Note if you have multiple steps you may need to rearrange the order of the Steps in the Omnscript.

Known Limitations

  • Large PDF files are not supported by this process. This process uses a prompt template to process a PDF file and return the fields or what the LLM considers to be fields in the PDF. At some point, the LLM will simply not return a valid response. It is unknown the exact size or limitation but the best guess is anything over 10 pages. You can always attempt to process the PDF and if the LLM does not successfully return a result an error will be presented. You can attempt to use PDF editing tools such as Adobe Acrobat Pro to split the PDF into multiple sections
  • At most this process can handle 100 fields, the current processes maxes out with Apex limits above this.
  • As the results are coming from an LLM and what it interprets as fields, checkboxes and radio groups, some results may not exactly match your understanding or believe about what these fields should be. You can still manually edit the results of the LLM.
  • This version supports Text, Number, Date, Radio (Single Selection) and Checkbox elements
  • All elements in this version are added with a width of 12

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •