Created
August 8, 2023 00:03
-
-
Save rabwill/84c1ac655ab25342a2e33564ffd3bfd5 to your computer and use it in GitHub Desktop.
GitHub Copilot blog handleTeamsMessagingExtensionQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async handleTeamsMessagingExtensionQuery(context, query) { | |
const searchQuery = query.parameters[0].value; | |
// const response = await axios.get( | |
// `http://registry.npmjs.com/-/v1/search?${querystring.stringify({ | |
// text: searchQuery, | |
// size: 8, | |
// })}` | |
// ); | |
// get response to get product based on name from querystring using the product API | |
const response = await axios.get( | |
`http://localhost:3978/api/products/${searchQuery}` | |
); | |
const attachments = []; | |
response.data.forEach((obj) => { | |
const heroCard = CardFactory.heroCard(obj.name); | |
const preview = CardFactory.heroCard(obj.name); | |
preview.content.tap = { | |
type: "invoke", | |
value: { name: obj.name, description: obj.description }, | |
}; | |
const attachment = { ...heroCard, preview }; | |
attachments.push(attachment); | |
}); | |
return { | |
composeExtension: { | |
type: "result", | |
attachmentLayout: "list", | |
attachments: attachments, | |
}, | |
}; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment