具有嵌入式 Web 视图的 Teams Messaging Extension - Web 应用程序的结构
Teams Messaging Extension with embedded web view - structure of web application
我再次需要有关消息扩展的帮助。我想在我的消息扩展中显示自定义 Web 视图,例如此处 https://docs.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/action-commands/create-task-module?tabs=dotnet(“使用嵌入式 Web 视图”)。
我现在不明白 Web 应用程序必须如何编写以及消息扩展是什么doing/calling。所以只输入一个正常的 url 是行不通的,我已经测试过了。
有谁能解释我的 Web 应用程序需要哪种 endpoint/structure 才能被消息扩展成功调用?我对 MS 提供的文档有点困惑。
感谢您的帮助!
更新:
我想更详细地描述我在做什么
- 在用户单击我的 bot 中的消息传递扩展后,将调用“OnTeamsMessagingExtensionFetchTaskAsyn”。
- 然后执行以下内容:
'
var response = new MessagingExtensionActionResponse()
{
Task = new TaskModuleContinueResponse()
{
Value = new TaskModuleTaskInfo()
{
Height = "large",
Width = "large",
Title = "Example task module",
Url = "https://xxxxxx.eu.ngrok.io/messages/messages",
},
},
};
return response;
- 当我在“https://xxxxxx.eu.ngrok.io/messages/messages”上调试我的 Web 应用程序时,我看到 MessagesController 被调用,然后它想要显示相应的视图
'
public IActionResult Messages()
{
return View();
}
public MessagesController()
{
}
但是页面没有显示。 Teams 说它无法访问该应用程序。
更新 2
我将我的 Web 应用程序的域添加到清单中的“messageHandlers”,但它不起作用
当用户点击附加信息时网站没有显示
然后我尝试了另一种类型的 ActionResponse(用于配置的那种)并且有效
return new MessagingExtensionActionResponse
{
ComposeExtension = new MessagingExtensionResult
{
Type = "config",
SuggestedActions = new MessagingExtensionSuggestedAction
{
Actions = new List<CardAction>
{
new CardAction
{
Type = ActionTypes.OpenUrl,
Value = "https://xxxxx.eu.ngrok.io/messages/messages",
},
},
},
},
};
更新 3
图 1 - 显示浏览器开发工具,已建立与网站的连接
图 2 - 使用开发工具我强迫团队加载 iframe
我建议您查看为此提供的各种示例。 Bot Framework 示例库中有示例 (https://github.com/pnp/teams-dev-samples/tree/master/samples) and also in the Teams PnP Samples (https://github.com/pnp/teams-dev-samples/tree/master/samples). You can also look in the overall Teams Sample gallery viewer at https://pnp.github.io/teams-dev-samples/.
评论里议论纷纷,最后把showLoadingIndicator
设置为true
,这也是本题的一个复杂因素,需要改一下(或在网页中处理得更好 - 请参阅此处了解更多信息:)
我再次需要有关消息扩展的帮助。我想在我的消息扩展中显示自定义 Web 视图,例如此处 https://docs.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/action-commands/create-task-module?tabs=dotnet(“使用嵌入式 Web 视图”)。 我现在不明白 Web 应用程序必须如何编写以及消息扩展是什么doing/calling。所以只输入一个正常的 url 是行不通的,我已经测试过了。 有谁能解释我的 Web 应用程序需要哪种 endpoint/structure 才能被消息扩展成功调用?我对 MS 提供的文档有点困惑。
感谢您的帮助!
更新: 我想更详细地描述我在做什么
- 在用户单击我的 bot 中的消息传递扩展后,将调用“OnTeamsMessagingExtensionFetchTaskAsyn”。
- 然后执行以下内容:
'
var response = new MessagingExtensionActionResponse()
{
Task = new TaskModuleContinueResponse()
{
Value = new TaskModuleTaskInfo()
{
Height = "large",
Width = "large",
Title = "Example task module",
Url = "https://xxxxxx.eu.ngrok.io/messages/messages",
},
},
};
return response;
- 当我在“https://xxxxxx.eu.ngrok.io/messages/messages”上调试我的 Web 应用程序时,我看到 MessagesController 被调用,然后它想要显示相应的视图
'
public IActionResult Messages()
{
return View();
}
public MessagesController()
{
}
但是页面没有显示。 Teams 说它无法访问该应用程序。
更新 2
我将我的 Web 应用程序的域添加到清单中的“messageHandlers”,但它不起作用
当用户点击附加信息时网站没有显示
然后我尝试了另一种类型的 ActionResponse(用于配置的那种)并且有效
return new MessagingExtensionActionResponse { ComposeExtension = new MessagingExtensionResult { Type = "config", SuggestedActions = new MessagingExtensionSuggestedAction { Actions = new List<CardAction> { new CardAction { Type = ActionTypes.OpenUrl, Value = "https://xxxxx.eu.ngrok.io/messages/messages", }, }, }, }, };
更新 3
我建议您查看为此提供的各种示例。 Bot Framework 示例库中有示例 (https://github.com/pnp/teams-dev-samples/tree/master/samples) and also in the Teams PnP Samples (https://github.com/pnp/teams-dev-samples/tree/master/samples). You can also look in the overall Teams Sample gallery viewer at https://pnp.github.io/teams-dev-samples/.
评论里议论纷纷,最后把showLoadingIndicator
设置为true
,这也是本题的一个复杂因素,需要改一下(或在网页中处理得更好 - 请参阅此处了解更多信息: