SharinPix Generative AI Analysis/Extract Image Capabilities

This article demonstrates how to use the latest GPT models to integrate AI capabilities with SharinPix Images.

In the following sections, you will learn:

Information:

The AIConnect feature can be used:

  • In your own Lightning Component development
  • In Flows

Note:

To be able to use this feature, you will need an OpenAI API key.

Prerequisite

To insert your OpenAI API key, you need to go to SharinPix Settings.

After saving your OpenAI API key, you are good to go.

SharinPix Playground

The SharinPix Playground is a tab on the SharinPix App, which allows users to test the Al Image capabilities as shown in the diagram below,

On the SharinPix Playground page, we have a SharinPix Album with prompt and result text boxes. The AI feature is called when the "Extract" button is clicked. The "Extract" button runs the Prompt entered against the image being viewed and updates the Result text box with the response.

AIConnect

The SharinPix package provides the Apex class, AIConnect, which includes methods that integrate OpenAI features. This enables us to execute prompts against the ChatGPT model, using images uploaded to SharinPix.

AIConnect Example

extractImageInfo

global static String extractImageInfo(String imageUrl, String prompt)

  • This method can be used to extract information according to the prompt provided from the image using the imageUrl.

String url = 'https://p.sharinpix.com/image.png';
String prompt = 'Provide the licenses plate number found on the image';
String result = sharinpix.AIConnect.extractImageInfo(url, prompt);
System.debug('result: ' + result);

Using AIConnect in Flows

Using AIConnect in a Screen Flow

AIConnectAutomation is an Apex Invocable method that uses the AIConnect class. This enables the use of AIConnect in a Screen Flow to analyze SharinPix images using a prompt provided by the user.

This section demonstrates how to build a flow that allows the user to input a custom prompt, select a single image from a SharinPix Album, and display the AI-generated analysis result in real time.

Warning


This setup is optimized to analyze one image at a time. If the user selects multiple images, the flow will fail. For analyzing multiple images at once, refer to the SharinPix AI Extractor documentation.

Flow Configuration Overview:

Below is a visual representation of the flow:

  1. Screen – Prompt input and image selection
  2. Assignment – Create and assign variables
  3. Get Records – Retrieve the selected image
  4. Apex Action – Call AIConnectAutomation
  5. Screen – Display the AI-generated response

Step-by-Step Setup

Step 1: Create a New Screen Flow

  • Go to Setup > Flows and create a new Screen Flow.

Step 2: Add a Screen – “Select Image to Analyse”

  • Add a Long Text Area input for the user to type the AI prompt.
  • Below that, insert a SharinPix Album component for image selection.
    • In the AlbumId field, create a new resource of type Variable and Data Type Text. For the API Name, please type in " recordId "

Step 3: Add an Assignment – “Set Prompt and Image”

  • Create two variables:
    1. selectedImage
      • Resource Type: Variable
      • Data Type: Text
      • Allow multiple values (collection): ✅ (Ticked)
    2. prompt
      • Resource Type: Variable
      • Data Type: Text
  • Assign:
    • selectedImage ← selected image ID from album component from Select Image to Analyse screen
    • prompt ← user-entered prompt from Select Image to Analyse screen

 

Step 4: Add a Get Records Element – “Get SharinPix Image”

  • Object: SharinPix__Image__c
  • Condition Requirements:
    • sharinpix__ImagePublicId__c IN selectedImage
  • Store:
    • Only the first record
    • Automatically store all fields

Step 5: Add Apex Action – “Analyse Image”

  • Search for and add AIConnectAutomation.
  • Input values:
    • Image URL: Get_SharinPix_Image.sharinpix__ImageURLFull__c
    • Prompt: prompt

Step 6: Add a Screen – “Display Analysis”

  • Add a Read-only Long Text Area or Display Text component and set its default value to the output from the Apex Action. In this case Text from Analyse_Image.

After sending the request, the AI-generated response will be displayed to the user in this screen.

Demo

Step 1 : Put your flow on the record page and make sure to tick the box to pass in the record ID to the flow.

Step 2: On your record page, select the image you want to analyse and and type in your prompt. Click the next button to proceed to the results page.

The AI Analysis result will be displayed on the next screen

Using AIConnect in a Record Triggered Flow

  • Create a new Flow on SharinPix Image creation. The Flow will be triggered every time a SharinPix image is created, and then the response from the AIConnectAutomation will be updated in its Description field.
  • Since a Response is expected from the AIConnect call, you need to check the box:
    • “Include a Run Asynchronously path to access an external system after the original transaction for the triggering record is successfully committed“ as shown below.
  • Create a new resource (Constant) for a static prompt as follows.
  • Add an Apex Action and select the Apex class AIConnectAutomation.
  • Image URL: Enter the image's URL.
  • Prompt: Use the resource 'MyStaticPrompt' created earlier for the prompt.
  • Update the SharinPix Image Object with the response from AIConnectAutomation apex action.

Need help to write your GenAI image prompt?

The visual experts are here to help. Just send an email to [email protected] to get some help so we can explain you how we can deliver services through our experts to assist you on that duty!

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.