From 8841ff2da20b10f1da8bcd70d0c16f3bd057614f Mon Sep 17 00:00:00 2001 From: Bowen Song Date: Wed, 15 Jan 2025 12:34:17 +0800 Subject: [PATCH] fix(cea): fix cea code for custom api template (#13054) --- .../src/component/generator/apiSpec/helper.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/fx-core/src/component/generator/apiSpec/helper.ts b/packages/fx-core/src/component/generator/apiSpec/helper.ts index 67f7c90a63..9ceabca19a 100644 --- a/packages/fx-core/src/component/generator/apiSpec/helper.ts +++ b/packages/fx-core/src/component/generator/apiSpec/helper.ts @@ -1298,9 +1298,21 @@ app.ai.action("{{operationId}}", async (context, state, parameter) => { } const cardName = "{{operationId}}".replace(/[^a-zA-Z0-9]/g, "_"); const cardTemplatePath = path.join(__dirname, '../adaptiveCards', cardName + '.json'); + const isTeamsChannel = context.activity.channelId === Channels.Msteams; if (await fs.exists(cardTemplatePath)){ const card = generateAdaptiveCard(cardTemplatePath, result); - await context.sendActivity({ attachments: [card] }); + await context.sendActivity({ + attachments: [card], + ...(isTeamsChannel ? { channelData: { feedbackLoopEnabled: true }} : {}), + entities: [ + { + type: "https://schema.org/Message", + "@type": "Message", + "@context": "https://schema.org", + additionalType: ["AIGeneratedContent"], // AI Generated label + }, + ] + }); } else { await context.sendActivity(JSON.stringify(result.data)); @@ -1330,7 +1342,7 @@ app.ai.action("{{operationId}}", async (context: TurnContext, state: Application const card = generateAdaptiveCard(cardTemplatePath, result); await context.sendActivity({ attachments: [card], - ...(isTeamsChannel ? { channelData: true } : {}), + ...(isTeamsChannel ? { channelData: { feedbackLoopEnabled: true }} : {}), entities: [ { type: "https://schema.org/Message",