Skip to content

Commit 208bc39

Browse files
committed
feat: open bot via source file
1 parent b1bc8a0 commit 208bc39

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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)