Build Salesforce Agentforce using Agent Script in Visual Studio Code
Feb 24, 2026
Show More Show Less
View Video Transcript
0:08
Hello everyone. In this video, we are
0:11
going to see how to do agent script for
0:15
new agent force uh agent development
0:19
using visual studio code editor.
0:24
As a proc code developer, you might be
0:27
interested in making use of uh a code
0:29
editor to do the development.
0:33
For agent script, we can make use of
0:36
visual studio code editor and then we
0:38
can do the agent scripting so that we
0:42
will be able to validate which will
0:45
compile the agent script whatever we
0:48
have developed.
0:50
We will be able to preview the agent in
0:53
the visual studio code editor and also
0:56
we will be able to publish so that it
0:58
will be getting committed
1:01
for uh
1:03
uh um so whenever we wanted to create an
1:07
agent force agent we usually go to the
1:11
agent force studio and then we will be
1:14
able to click new agent and also we can
1:17
create the agent force agent using the
1:19
script.
1:21
So you can put a sample script so that
1:23
it will start building the agent force
1:25
agent uh for you.
1:28
But if you wanted to do the same thing
1:30
using Visual Studio Code Editor, then
1:33
make sure you have Salesforce CLA
1:35
installed in your uh PC
1:39
and also install Visual Studio Code
1:42
Editor.
1:44
In the Visual Studio Code Editor,
1:48
install
1:49
Salesforce extension pack. Once that is
1:52
done, you can create a new project. If
1:56
you wanted to create with manifest, make
1:58
use of create project with manifest
2:00
command. So that you will get the
2:02
package.xml file.
2:05
Let's say you have already done some
2:06
development using the Salesforce org in
2:10
the agent force studio. So we so let's
2:13
say you created an agent uh I in my org
2:17
I can see multiple agents which are
2:19
created using agent script here
2:22
in the visual studio code
2:25
under manifest folder select the
2:28
package.xml XML file. In this XML file,
2:33
make use of AA authoring bundle. I'm
2:36
using star in the members so that it
2:39
will fetch all the agent force agents
2:42
that are created using agent script.
2:44
Once you extract
2:47
under force app folder under main and
2:50
default, you should see a authoring
2:52
bundles folder. under that you should
2:55
see the agent force agent that are
2:57
created using agent script.
3:01
So here I'm going to make use of this uh
3:05
knowledge agent.
3:07
In this agent
3:10
I have general FAQ
3:14
off topic and ambiguous question.
3:18
This particular uh general FAQ topic is
3:21
connected
3:25
to my agent force data library.
3:28
So this is my data library.
3:32
All these things you should be able to
3:34
see it here if we use canvas also.
3:40
So the same agent force agent uh I'm
3:43
able to see it in my visual studio code.
3:52
In the package.xml you have to right
3:54
click and select sfdx retrieve source in
3:59
manifest
4:00
uh sorry retrieve source in manifest
4:02
from org command so that it will
4:04
retrieve all the agent force agents that
4:07
are developed using agent uh script.
4:12
Let's say you you have you are doing
4:14
some changes and then you wanted to
4:15
validate whether the agent script
4:17
whatever you have developed is correct u
4:20
by syntax and uh um and the compilation
4:25
will be successful. In order to compile
4:27
it
4:29
right click and select afdx
4:34
validate this agent.
4:37
If you wanted to create the agent from
4:39
the scratch directly from the visual
4:41
studio code then use
4:47
afdx create agent. When you make use of
4:51
this command you will be able to create
4:53
the agent force agent using agent script
4:56
directly in visual studio code editor.
5:01
Once you have validated, let's say you
5:03
wanted to
5:05
uh preview and test it whether there are
5:08
any um runtime exceptions or any issues
5:11
in the development. Right click the
5:14
agent file and make use of afdx preview
5:18
this agent command.
5:21
This uh afdx preview this agent command
5:23
will help you to test and preview the
5:26
agent directly from
5:28
VS code editor.
5:36
So here you can click start simulation.
5:39
You can also select whether it should be
5:40
a simulation or it should be a live
5:42
test. I have selected a live test.
5:46
Click start live test.
5:51
And then you should be
5:58
able to test it. I am one second.
6:02
There is some issue.
6:09
Okay. So,
6:12
how to expedite
6:15
my order? So, you will be able to test
6:20
um the same way how you can preview it
6:24
from your agent force builder.
6:31
So I'm able to test it. Let's say
6:34
whether the same testing result I'm
6:37
getting it from the agent force builder.
6:45
So currently I'm testing it from the
6:47
agent force builder.
6:49
I'm going to check whether the results
6:52
are same. I'm test I tested it from VS
6:54
code and I saw this is the response.
7:01
So the response what I got using the
7:03
agent force data library is up to date.
7:07
One important thing to note here is when
7:09
you preview the agent
7:12
by default it will be in simulation.
7:16
When you are doing the development you
7:18
can keep it as the default simulation.
7:21
do all the basic basic testing like unit
7:25
testing you are you can check whether
7:26
the actions are properly getting invoked
7:29
whether the right topic is getting
7:31
invoked you can make use of the agent
7:33
tracer to find out whether the right
7:35
topic and the actions are executed
7:39
make use of the start live test when you
7:42
are done with your development and then
7:43
you wanted to fine-tune and optimize
7:45
your agent so make use of this start
7:48
live test so that it will do the actual
7:51
Invocation of data library, the flow,
7:54
Apex, whatever actions is are configured
7:58
in your topics.
8:08
Please check the video description. In
8:09
the video description, I have given my
8:11
blog post. From the blog post you should
8:13
be able to get
8:15
the steps of whatever we discussed in
8:17
this video and also the sample
8:20
package.xml in order to fetch the
8:22
existing agent force agents developed
8:25
using agent script using visual studio
8:27
code editor.
8:35
I hope it was helpful.
8:45
Thank you for watching.
#Internet Software
