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 the object and related Salesforce objects to integrate actual Salesforce data into the dialogue with ChatGPT, and to get different answers for each record.
Ask questions about selected records, and if desired about records related to the initial records. For example, select a number of Accounts, and ask ChatGPT to summarize certain Cases related to each of those Accounts.
Store the ChatGPT 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:
- Go to Salesforce Setup > Settings: Security > Remote Site Settings.
- Click New Remote Site.
- Enter a name for the new remote site.
- At Remote Site URL, enter https://api.openai.com
- Make sure the Active box is ticked.
- Click Save.
- Set up the Ask ChatGPT action settings:
- Go to DAP Setup. At left, go to the Action Library. At the Ask ChatGPT action, click Edit.
- At OpenAI API Key, enter the API Key belonging to your OpenAI subscription.
- 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. - 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.
Using the Action
- Select the records that you want to apply the action to in a list view, or by creating a new job.
- In the Action Launcher (top right in list view, or the next window in the DAP Job modal), select Ask ChatGPT and click Next.
- In the next window, fill in the fields:
- At Prompt, fill in the prompt you want to use.
- Add Field Variables in the prompt (optional): place the cursor at the right spot in the text and click </> Insert Field Variable . Select the field you want to use the values of.
- Add data from related records (optional).
Read more about this below at "Attach Data from Related Records".- Click + Attach Data from Related Records .
- At Lookup Object, select the related object to add data from.
- Click + Add Filter (optional) to only use certain related records.
- Enter a Follow-up Prompt about the related records. Use Field Variables if needed. The follow-up Prompt will be repeated for each related record, and sent to ChatGTP as one large prompt together with the main prompt.
- If you change your mind and do not want to use data from related records after all, click + Remove Data from Related Records to remove the related data configuration from the action.
- At Result Field, select a text field or picklist where you want to record the answers as returned by ChatGPT.
- The Maximum Token Response Size shows the maximum output token size based on the size of the selected Result Field. The size set here makes sure that ChatGPT does not give an answer that is larger than would fit in the result field. A larger token response size would unnecessarily use up extra tokens, as the last part of larger answers cannot be stored in the result field. You can set a smaller token response size to get smaller answers and reduce cost.
Read more about tokens here. - Click Next.
- In the confirmation window, check the details for the action, and click Start.
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.
Attach Data from Related Records (optional)
Combine data from records with data from their related records, and ask questions to ChatGPT based on this combined data, with the option "Attach Data from Related Records".
First you enter the main prompt, in which you can refer to information that will be gathered later on in the follow-up prompts. Then enter a follow-up prompt to gather data from the related records. It is recommended to include a field variable for the related record's name, ID, or other unique field in the follow-up prompt, so ChatGPT can distinguish between data from the different related records more easily.
Upon execution, the follow-up prompt is repeated for each of the related records. The main prompt and follow-up prompts are then sent together to ChatGPT as one API request. Do keep in mind that every OpenAI model has a context window limit.
ChatGPT answers, and the answer is stored in a field on the initial record.
For example, select a number of Accounts, and ask ChatGPT to summarize certain Cases related to each of those Accounts. The Case summaries will then be stored in a field on the Account records.
Other use cases are, again with the example of Cases related to Accounts: asking for a trend in related cases created in the past three months, the most pressing case per account, etc. Or, ask ChatGPT to analyze all related Opportunities of an Account, and to create a financial report based on its analysis. The possibilities are endless.
Well, almost endless. The maximum of related records for synchronous execution is 9,999 related records per initial record, if the chunk size is 1. For asynchronous execution this limit is higher.
Examples
Object | Prompt | Result Field |
---|---|---|
Case | Please summarize this customer case by studying the Case Subject: "{!Subject}" and description: "{!Description}". Your response must use bullet points. Summarize 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, a picklist 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 |
Account and related Opportunities |
Prompt: Please generate a financial report about the following opportunity data that I will share with you, related to account {!Name}. The financial report should be interesting to a CRO persona. Please return plain text, no markup. Follow-up Prompt: Opportunity Name: {!Name} Opportunity Stage: {!StageName} Opportunity Amount: {!Amount} Opportunity Close Date: {!CloseDate} Opportunity Created Date: {!CreatedDate} Opportunity Type: {!Type} |
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.