我想实现当用户从Input.ChoiceSet中显示的列表中选择标签时,它调用handleTeamsMessagingExtensionSelectItem的功能。
我当前的代码如下。
actionApp.ts
public async onInvokeActivity(context: any): Promise<any> {
console.log("context.activity.name is ", context.activity.name);
if (context.activity.name == "application/search") {
let searchQuery = context.activity.value.queryText;
////other code///
}
if (context.activity.name == "composeExtension/selectItem") {
console.log("select item is called");
return TeamsBot.createInvokeResponse(
await this.handleTeamsMessagingExtensionSelectItem(
context,
context.activity.value
)
);
}
return super.onInvokeActivity(context);
}
public async handleTeamsMessagingExtensionSelectItem(
context: TurnContext,
obj: any
): Promise<any> {
console.log("tag is choosed");
return {};
}
manifest.json
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
"version": "1.0.0",
"id": "${{TEAMS_APP_ID}}",
"packageName": "com.microsoft.teams.extension",
"developer": {
"name": "Teams App, Inc.",
"websiteUrl": "https://www.example.com",
"privacyUrl": "https://www.example.com/termofuse",
"termsOfUseUrl": "https://www.example.com/privacy"
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"name": {
"short": "ms-extension${{APP_NAME_SUFFIX}}",
"full": "full name for ms-extension"
},
"description": {
"short": "short description of ms-extension",
"full": "full description of ms-extension"
},
"accentColor": "#FFFFFF",
"bots": [ {
"botId": "${{BOT_ID}}",
"scopes": ["personal", "team"],
"needsChannelSelector": false,
"isNotificationOnly": false,
"commandLists": [
{
"scopes": ["personal", "team"],
"commands": [
{
"title": "staticsearch",
"description": "To get static type ahead search Adaptive Card"
},
{
"title": "dynamicsearch",
"description": "To get dynamic type ahead search Adaptive Card"
}
]
}
]
}],
"composeExtensions": [
{
"botId": "${{BOT_ID}}",
"canUpdateConfiguration": true,
"commands": [
{
"id": "bookmarkMessage",
"type": "action",
"title": "bookmark this message",
"description": "bookmark this message",
"initialRun": false,
"fetchTask": true,
"context": [
"compose",
"message",
"commandBox"
]
},
{
"id": "tagsChoiceSet",
"type": "query",
"title": "Find tag",
"description": "",
"initialRun": false,
"fetchTask": true,
"context": [
"commandBox",
"message",
"compose"
],
"parameters": [
{
"name": "tagsChoiceSet",
"title": "Search keyword",
"description": "Search keyword",
"inputType": "choiceset"
}
]
}
]
}
],
"configurableTabs": [],
"staticTabs": [],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"${{BOT_DOMAIN}}"
]
}
我读了this,我假设
"composeExtension/selectItem"
是用户从列表中选择标签时的情况,但似乎并非如此。
我错过了什么吗?
handleTeamsMessagingExtensionSelectItem 方法适用于消息扩展搜索列表项。 一旦你从ME中选择任何列表项,它就会调用这个方法,但它不适用于Input.ChoiceSet的列表。