Skip to content

Commit 1232d27

Browse files
authored
Merge pull request #1230 from salesforcecli/ew/open-bot
Open bot via the `--source-file` flag
2 parents c20cdc1 + c8fe7e0 commit 1232d27

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

messages/open.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Open your default scratch org, or another specified org, in a browser.
66

77
To open a specific page, specify the portion of the URL after "https://mydomain.my.salesforce.com" as the value for the --path flag. For example, specify "--path lightning" to open Lightning Experience, or specify "--path /apex/YourPage" to open a Visualforce page.
88

9-
Use the --source-file to open a Lightning Page from your local project in Lightning App Builder. Lightning page files have the suffix .flexipage-meta.xml, and are stored in the "flexipages" directory.
9+
Use the --source-file flag to open ApexPage, FlexiPage, Flow, or Agent metadata from your local project in the associated Builder within the Org.
1010

1111
To generate a URL but not launch it in your browser, specify --url-only.
1212

@@ -38,6 +38,10 @@ To open in a specific browser, use the --browser flag. Supported browsers are "c
3838

3939
$ <%= config.bin %> <%= command.id %> --source-file force-app/main/default/flows/Hello.flow-meta.xml
4040

41+
- Open local Agent metadata (Bot) in Agent Builder:
42+
43+
$ <%= config.bin %> <%= command.id %> --source-file force-app/main/default/bots/Coral_Cloud_Agent/Coral_Cloud_Agent.bot-meta.xml
44+
4145
# flags.private.summary
4246

4347
Open the org in the default browser using private (incognito) mode.
@@ -48,7 +52,7 @@ Browser where the org opens.
4852

4953
# flags.source-file.summary
5054

51-
Path to an ApexPage or FlexiPage to open in Lightning App Builder.
55+
Path to ApexPage, FlexiPage, Flow, or Agent metadata to open in the associated Builder.
5256

5357
# flags.path.summary
5458

@@ -82,7 +86,7 @@ The Lightning Experience-enabled custom domain is unavailable.
8286

8387
# FlowIdNotFound
8488

85-
No ID not found for Flow %s.
89+
ID not found for Flow %s.
8690

8791
# FlowIdNotFound.actions
8892

src/commands/org/open.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ const generateFileUrl = async (file: string, conn: Connection): Promise<string>
176176
const typeName = components[0]?.type?.name;
177177

178178
switch (typeName) {
179+
case 'Bot':
180+
return `AiCopilot/copilotStudio.app#/copilot/builder?copilotId=${await botFileNameToId(conn, file)}`;
179181
case 'ApexPage':
180182
return `/apex/${path.basename(file).replace('.page-meta.xml', '').replace('.page', '')}`;
181183
case 'Flow':
@@ -193,6 +195,13 @@ const generateFileUrl = async (file: string, conn: Connection): Promise<string>
193195
}
194196
};
195197

198+
const botFileNameToId = async (conn: Connection, filePath: string): Promise<string> =>
199+
(
200+
await conn.singleRecordQuery<{ Id: string }>(
201+
`SELECT id FROM BotDefinition WHERE DeveloperName='${path.basename(filePath, '.bot-meta.xml')}'`
202+
)
203+
).Id;
204+
196205
/** query flexipage via toolingPAI to get its ID (starts with 0M0) */
197206
const flexiPageFilenameToId = async (conn: Connection, filePath: string): Promise<string> =>
198207
(
@@ -228,7 +237,7 @@ const getFileContents = (
228237
<body onload="document.body.firstElementChild.submit()">
229238
<form method="POST" action="${instanceUrl}/secur/frontdoor.jsp">
230239
<input type="hidden" name="sid" value="${authToken}" />
231-
<input type="hidden" name="retURL" value="${retUrl}" />
240+
<input type="hidden" name="retURL" value="${retUrl}" />
232241
</form>
233242
</body>
234243
</html>`;

0 commit comments

Comments
 (0)