Skip to content

Instantly share code, notes, and snippets.

@rabwill
Created August 8, 2023 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rabwill/84c1ac655ab25342a2e33564ffd3bfd5 to your computer and use it in GitHub Desktop.
Save rabwill/84c1ac655ab25342a2e33564ffd3bfd5 to your computer and use it in GitHub Desktop.
GitHub Copilot blog handleTeamsMessagingExtensionQuery
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