Image created by DALL-E 3 based on a prompt by Bob Buzzard
Introduction
One of the key features of Einstein Copilot from Salesforce is its
extensibility - while there are a bunch of standard actions, and many more
coming, there will always be something more you want to give your users.
Custom actions allow you to create an AI assistant that targets your specific
business challenges, adding capabilities to your copilot that generate real
value for your users.
Scenario
In my last post, I introduced the
Sales Coach
- a custom Lightning Web Component that you add to an Opportunity record page.
When the Sales Coach component renders, it executes Apex code to hydrate a
prompt template with details of the Opportunity and request some guidance from
an LLM.
While this works well for users that are viewing an Opportunity record, I also
want to provide a way tfor users receive guidance on deals while they are in
another part of the Salesforce application - their Home Page, for example.
Creating the Custom Copilot Action
Custom Copilot Actions can be created using Apex, Flow or Prompt Templates.
I've gone for a Prompt Template, as I already have this in place for the Sales
Coach component. Once I choose the Reference Action Type of Prompt Template, I
get to select from a list of existing prompts in the Reference Action
selector.
Once I've chosen my action, I provide details of how the Copilot can use it :
The Copilot Action Instructions is pre-populated from my Prompt Template
description. As I want to use it in exactly the same way, I can leave that
alone. I then provide the instructions around the Candidate Opportunity input,
and check the box in the Output section to Show in conversation - without
this, the user won't be able to receive the coaching they so richly deserve.
Note that while the Prompt Template pull several fields from the Opportunity
record - Name, Amount, Close Date, Stage Name - I don't need to specify any of
this information here. I don't even need to specify that it's an Opportunity
record - that is picked up automatically from the Prompt Template input.
Pretty simple really.
Once my custom action is created, I need to add it to the Copilot. I do this
via the Copilot Builder, selecting my new action from the list of available
actions and then clicking a button to add it to the Active Copilot :
As an aside, this Copilot isn't Active yet, so the text in the button is
slightly misleading, but not a big deal as I can only have one Copilot so I'm
hardly likely to get confused.
Putting it Together
Remember earlier when I created the Copilot action I gave it details of how to
use it? The Copilot Action Instructions field does what it says on the tin -
it instructs the Copilot as to the purpose of the action and when it should be
used:
I've defined this as providing advice to progress a specific opportunity, so
in order to include the action in the Copilot plan, I need to ask the it to
help me do that. As we're in AI world, I don't need to be as obvious as asking
for advice to progress an opportunity, instead I used my own words and asked for "help to win a deal".
Interestingly, when I ran this to capture the screenshots, Copilot told me
that it was following the instructions that I'd provided for the action, which
I hadn't seen before:
Something to remember when using Prompt Template actions is they will lead to a
slower response time, as each one involves a round trip to an LLM. There will
always be one round trip, to create the plan, but if you manage to generate a
request that involves multiple Prompt Template actions, there will be separate
requests made for each of those, and you'll be consuming additional
tokens.
No comments:
Post a Comment