Ask ChatGPT action

DAP action

Last published at: 2024-05-27 10:12:10 UTC
Delete

The Ask ChatGPT action is available for the Premium and PDM editions.

Use the Ask ChatGPT action to apply the strength of artificial intelligence to your daily operations. Use the action via the action launcher to get suggestions from ChatGPT for your specific questions related to the records you selected, or create macros with preconfigured prompts and reply-fields for repeated use in batch jobs and flows, or by your co-workers. Apply field variables from any Salesforce object to integrate actual Salesforce data into the dialogue with ChatGPT, and to get different answers for each record. Store the responses in your Salesforce records for further processing. 

A number of examples and use cases are listed below; get more ideas for how to use the Ask ChatGPT action from our blog here

Prerequisites

Before you can start using the Ask ChatGPT action, make sure you have done the following:

  • Subscribe to OpenAI's ChatGPT service at https://openai.com/pricing. The Ask ChatGPT action can use text-based models such as GPT-4, GPT-4 Turbo, GPT-3.5 Turbo, etc.
  • Enable remote site settings to allow Salesforce to call out to ChatGPT:
    1. Go to Salesforce Setup > Settings: Security > Remote Site Settings
    2. Click New Remote Site.
    3. Enter a name for the new remote site.
    4. At Remote Site URL, enter https://api.openai.com 
    5. Make sure the Active box is ticked. 
    6. Click Save.
  • Set up the Ask ChatGPT action settings:
    1. Go to DAP Setup. At left, go to the Action Library. At the Ask ChatGPT action, click Edit.
    2. At OpenAI API Key, enter the API Key belonging to your OpenAI subscription.
    3. At OpenAI Model, enter the API name of the OpenAI model you want to use.
      For example, enter gpt-4, gpt-4-1106-preview, or gpt-3.5-turbo.
    4. At OpenAI Temperature, enter a sampling temperature value between 0 and 2. Higher values like 1.5 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
Delete

Defining the right prompt

ChatGPT is a chatbot that will usually answer in full sentences. To have it return text that you can use in your records, you will have to tell it specifically what kind of answer you want. For example, if you want it to return one of the values of a picklist, add a sentence to the prompt listing all values of the picklist and say that it should only return one of those values. It's best to try it out with a text field first, to see what kind of answers you will get.

Add Field Variables to your prompt to use specific data from each record. You can either type out the field variables, or select them when using the action. See the examples below.

Note that you can enter a long prompt, but Salesforce field limits do apply.

Using the Action

  1. Select the records that you want to apply the action to in a list view, or by creating a new job.
  2. In the Action Launcher (top right in list view, or the next window in the DAP Job modal), select Ask ChatGPT and click Next.
  3. In the next window, fill in the fields:
    1. At Prompt, fill in the prompt you want to use. 
    2. If desired, add field variables: place the cursor at the right spot in the text and click </> Field Variable  . Select the field you want to use the values of.
    3. At Result Field, select a text field or picklist where you want to record the answers as returned by ChatGPT. 
    4. Click Next.
  4. In the confirmation window, check the details for the action, and click Start.
  5. If you ran the action from a list view: once the progress bar is at 100% completed, click Finish to return to the object overview.
    If you ran the action as a Job, you are returned to the Job Overview, where you can view the job results information via the Info button.

The answers that ChatGPT gave to your prompt are now saved on each record.

Delete

The Record Audit Log, if enabled, does not store the actual prompt and answer because of size limitations. It only records whether an answer was given or not.

Delete

Create a Macro

To use the action with the same prompt repeatedly, to use the action in batch jobs and flows, or to have your colleagues use the Ask ChatGPT action without them having to come up with a good prompt themselves, you can create a Macro‍. Assign the macro to users or profiles, and limit the use of the Ask ChatGPT action itself, to make sure ChatGPT is only used for certain prompts and result fields.

Examples

Object Prompt Result Field
Case Please summarise this customer case by studying the Case Subject: "{!Subject}" and description: "{!Description}". Your response must use bullet points. Summarise in a way so that a Customer Support employer working on this case can get the essence of the case quickly. Internal Comments
Case We are are car repair shop receiving customer cases with this subject "{!Subject}" and description "{!Description}". Please choose one of the following case reasons to determine the reason for this customer case: "Installation","Equipment Complexity","Performance","Breakdown","Equipment Design","Feedback" or "Other". Your response is limited to picking one of this reasons. if you cannot determine the correct reason please pick the option "Other". Case Reason, containing the case reasons listed in the prompt
Contact Please interpret the job title "{!Title}" and choose one of the following departments which this role is part of: Human Resources, Finance, Accounting, Sales, Marketing, Customer Support, Customer Success, Information Technology, Executive Management, Other. Your response should be limited to picking one of these departments. For example, your response could be "Customer Support". Do not reply with any other words. If the job title is not part of any of these departments, reply with the word "Other". Department
Account Please write me a bulleted pitch to tell {!Name} why they need <enter your product here> to solve their <enter a problem here> issues. A text field

Use Cases

Watch an example of how you can combine the forces of ChatGPT and Plauti's Data Action Platform to automatically analyze contacts and set their departments:

Watch an example of how you can combine the forces of ChatGPT and Plauti's Data Action Platform to analyze Cases and set the right Department:

Use your own classes for even more options

The Ask ChatGPT action can do a lot, but it is limited to the Object fields to retrieve information from. For example, for Cases you can only use information from fields such as the Description to use in questions for ChatGPT. If you'd like to use other data sources, such as case emails for Cases, you can build your own class and action. Create a class for DAP that calls the ChatGPT API, and include all Object data you want to provide. Then run the class you created with the Run An Apex Class action. Ofcourse you can then also create a Macro for this action.

Or, to expand your options for using the ChatGPT answers, you can also implement the Ask ChatGPT action in a class, and create or update other Objects with the responses returned by ChatGPT. Send an Email Message, create a new Task, add a note to an Opportunity, the possibilities are endless. Read more about using an action in a class: Start an Action from an Apex Class.‍ 

Delete

Using ChatGPT

For subjects related to the use of ChatGPT, such as accuracy or data privacy, we kindly refer you to the information provided by OpenAI on their website.