Example for Teams link unfurling #138
-
Describe your user scenario
Describe the solution you'd like
Describe alternatives you've considered
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @yukun-dong,
app.messageExtensions.queryLink('unfurlCmd', async (context, state): MessageExtensionActionResponse => {
// get url from activity (or possibly parse url from text)
const queryLink = context.activity.value
// TODO: validate queryLink is valid URL
// TODO: potentially do API call with valid URL to get details (e.g. image url, title, etc) e.g.:
const response = await axios.get(queryLink.ApiCall());
const card = AdaptiveCardPayload; // AdaptiveCardPayload can be a pre-formatted Adaptive Card json file.
card.imageUrl = response.image.imgUrl;
card.subtitle = response.image.altText;
return card;
});
// result: new activity with Adaptive Card attachment is sent Since there's plenty of documentation already in existence, I think that a sample will be unnecessary. :) |
Beta Was this translation helpful? Give feedback.
-
Hi @corinagum , thanks for the reply. |
Beta Was this translation helpful? Give feedback.
-
@yukun-dong The command id can be whatever you (the developer) wants it to be. The first parameter is the string or RegExp pattern you will use to call it within the bot, as needed. Since the code for this sends the activity, you will want to call it explicitly. /**
* Registers a handler that implements a Link Unfurling based Message Extension.
* @param commandId ID of the command(s) to register the handler for.
* @param handler Function to call when the command is received.
* @param handler.context Context for the current turn of conversation with the user.
* @param handler.state Current state of the turn.
* @param handler.url The URL that should be unfurled.
* @returns The application for chaining purposes.
*/
public queryLink( |
Beta Was this translation helpful? Give feedback.
Hi @yukun-dong,
composeExtensions