Forum Discussion
Ben-Error
Jan 29, 2025Copper Contributor
Declarative Agent - Adaptive Card showing only "sometimes"
I am creating a declarative Agent using VS Code. I followed this tutorial: https://learn.microsoft.com/en-us/training/modules/copilot-declarative-agent-action-api-plugin-adaptive-cards-vsc/3-exercise-return-rich-responses-adaptive-cards
Problem
Moving on from the tutorial to my actual application, I see that the Adaptive Card is rendering only in 50% of cases (and it should be in 100% of cases).
expected behavior
I use the chatbot to make a POST request to my API. The response should be rendered in an adaptive card.
relevant code elements of my app
openapi.json : OpenAPI Specs (JSON) - please not I inserted a lot of "Something" for privacy reasons.
{
"openapi": "3.0.0",
"info": {
"title": "something",
"version": "2",
"description": "some description",
"contact": { "name": "some name", "url": "some url" }
},
"servers": [{ "url": "some server", "description": "some description" }],
"paths": {
"/chat/generate": {
"post": {
"summary": "something",
"description": "Something",
"operationId": "generateSomething",
"parameters": [
{
"name": "Something-1",
"in": "header",
"required": true,
"description": "Something",
"schema": { "type": "string" }
},
{
"name": "Something-2",
"in": "header",
"required": true,
"description": "Something",
"schema": { "type": "string" }
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"v": {
"type": "string",
"description": "Specifies the API version being used.",
"default": "2"
},
"slidecode": {
"type": "object",
"properties": {
"title": { "type": "string", "description": "Something" },
"subtitle": {
"type": "string",
"description": "Something"
},
"slidenum": {
"type": "integer",
"description": "Something"
},
"image_id": {
"type": "string",
"description": "Something"
},
"body": {
"type": "array",
"items": {
"type": "object",
"properties": {
"point": {
"type": "string",
"description": "Something"
},
"description": {
"type": "string",
"description": "Something"
},
"icon": {
"type": "string",
"description": "Something"
}
},
"required": ["point", "description", "icon"]
}
},
"talktrack": {
"type": "string",
"description": "Something"
},
"sources": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Something"
},
"link": {
"type": "string",
"description": "Something"
}
},
"required": ["title", "link"]
}
},
"force_edit": {
"type": "boolean",
"description": "Something"
}
},
"required": [
"title",
"subtitle",
"slidenum",
"image_id",
"body",
"talktrack",
"sources",
"force_edit"
]
}
},
"required": ["v", "slidecode"]
}
}
}
},
"responses": {
"200": {
"description": "Something",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"image_url": {
"type": "string",
"description": "Something"
},
"presentation_view_url": {
"type": "string",
"description": "Something"
}
}
}
}
}
}
}
}
}
}
}
}
}
ai-plugin.json
{
"$schema": "https://developer.microsoft.com/json-schemas/copilot/plugin/v2.2/schema.json",
"schema_version": "v2.2",
"name_for_human": "Something",
"description_for_human": "Something",
"namespace": "Some-Namespace",
"functions": [
{
"name": "generateSomething",
"description": "Something",
"capabilities": {
"response_semantics": {
"data_path": "$.data",
"properties": {
"title": "$.presentation_view_url",
"url": "$.image_url"
},
"static_template": {
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{
"type": "Container",
"items": [
{ "type": "Image", "url": "${image_url}", "size": "large" },
{
"type": "TextBlock",
"text": "${presentation_view_url}",
"weight": "Bolder"
}
]
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "Get Something",
"url": "${presentation_view_url}"
}
]
}
}
}
}
],
"runtimes": [
{
"type": "OpenApi",
"auth": { "type": "None" },
"spec": { "url": "apiSpecificationFile/openapi.json" },
"run_for_functions": ["generateSomething"]
}
],
"capabilities": {
"conversation_starters": [
{ "text": "Something" },
{ "text": "Something 2" }
]
}
}
instruction.txt
# Copilot Agent Instructions
## Agent Identity You are doing SOMETHING
## Core Process
### Creation something
- execute `POST /chat/generate` API call - Include the following required headers in the API call:
1. `something1`: something
2. `something2`: something
- Ensure the API POST request includes the correct body (payload) with
1. the version `v` set to `2`
2. `slidecode` is an object with the following properties
2.1 `title` is something
2.2 `subtitle` is something
2.2 `slidenum` set to `1`
2.3 `image_id` set to `something`
2.4 `body` is a an array of 2 (two) objects, that have the required the properties `point`, `description` and `icon` - `icon` is a class name of Font Awesome Free 5.15 icon
2.5 `talktrack` is something
2.6 `sources` is a an array of 1 (one) object, that has the properties `title` and `link`, that both contain an empty string
2.7 `force_edit` is a boolen set to `true`
- Example 1 for a `POST /chat/generate` body (payload) about something:
`
json
{
"v": "2",
"slidecode": {
"title": "something",
"subtitle": "something",
"slidenum": "1",
"image_id": "something",
"body": [
{ "point": "point", "description": "blub", "icon": "icon" },
{ "point": "blub2", "description": "something", "icon": "icon" }
],
"talktrack": "something",
"sources": [{ "title": "", "link": "" }],
"force_edit": "true"
}
}
`
No RepliesBe the first to reply