Teams Bot erhalten keine Nachrichten von Teams [geschlossen]C#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Teams Bot erhalten keine Nachrichten von Teams [geschlossen]

Post by Anonymous »

Ich habe einen Bot, den ich für Teams baue. Der Bot wird in einer Azure -Web -App ausgeführt. Es sendet eine Begrüßungsnachricht und empfängt Nachrichten in der Registrierung von Azure Bot in dem Client "Testen im Web -Chat" -Klient. Ich habe auch eine Protokollnachricht in meinem Post -Controller, das ein Protokoll erfasst, wenn die Web -Chat -Konversationen stattfinden. Ich habe auch den "Teams Channel" in der Registrierung der Bot -Kanäle hinzugefügt, und alle Registrierungen werden "gesunde" angezeigt (direkte Linie, Web -Chat und Teams - ich brauche nur Teams, aber die anderen sind standardmäßig immer noch da). Die Teams geben keinen Fehler an (wie es würde, wenn die Registrierung der Bot -Kanäle fehlt), und es zeigt, dass die Nachricht gut gesendet wurde, aber es wird nie an meinem Endpunkt getroffen. Der Endpunkt schreibt, wie ich bereits erwähnt habe, eine Protokollnachricht im Web -Post -Handler. Bevor der Bot -Framework -Code überhaupt beginnt, wird überhaupt nicht getroffen. Alles sieht überall total gut aus.

Code: Select all

{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
"version": "1.0.4",
"id": "cbb5c179-99bc-4e95-a718-61c204eebc20",
"packageName": "com.abc.def",
"developer": {
"name": "test",
"websiteUrl": "https://www.test.com",
"privacyUrl": "https://www.teams.com/privacy",
"termsOfUseUrl": "https://www.teams.com/termsofuser"
},
"icons": {
"outline": "icon-outline.png",
"color": "icon-color.png"
},
"name": {
"short": "BotTest",
"full": "Test Bot"
},
"description": {
"short": "tbd...",
"full": "tbd..."
},
"accentColor": "#FFFFFF",
"bots": [
{
"botId": "7f7910a8-2910-4145-814f-630f344223be",
"scopes": [
"personal"
],
"isNotificationOnly": false,
"supportsCalling": false,
"supportsVideo": false,
"supportsFiles": false,
"commandLists": [
{
"scopes": [
"personal"
],
"commands": []
}
]
}
],
"webApplicationInfo": {
"id": "7f7910a8-2910-4145-814f-630f344223be",
"resource": "api://ph0jaaa4-7063.use.devtunnels.ms/7f7910a8-2910-4145-814f-630f344223be"
},
"permissions": [
"identity"
],
"validDomains": [
"token.botframework.com",
"ph0jhmk4-7063.use.devtunnels.ms"
],
"devicePermissions": [
"notifications",
"openExternal"
]
}
< /code>
Und hier ist der Controller (es ist eine C# Web-App): < /p>
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;

namespace MyBot.WebApp.Controllers;

[Route("api/MyEndpoint")]
[ApiController]
public class BotController : ControllerBase
{
private readonly IBotFrameworkHttpAdapter _adapter;
private readonly IBot _bot;
private readonly ILogger _logger;

public BotController(IBotFrameworkHttpAdapter adapter, IBot bot, ILoggerFactory loggerFactory = null)
{
_adapter = adapter;
_bot = bot;

if (loggerFactory != null)
{
_logger = loggerFactory.CreateLogger();
}
}

[HttpPost]
public async Task PostAsync()
{
_logger?.LogInformation(@"In PostAsync");

try
{
await _adapter.ProcessAsync(Request, Response, _bot);
}
catch (Exception ex)
{
_logger?.LogCritical(@"Exception: " + ex);
}
}
}
Der Bot wird auf 'API/Myendpoint' ausgeführt, nicht 'Nachrichten', aber er ist in der Bot -Registrierung korrekt und erinnert sich, dass er im Azure 'Test im Web -Chat' funktioniert. Im Wesentlichen wird aus den Teams die in postasynchronisierte Nachricht nie protokolliert, aber wenn ich vom Azure 'Test im Web -Chat -Bildschirm aufrufe. Das Portal in Azure sieht gut aus, aber vielleicht ist der Teams Channel unter den Cover fehlerhaft? Hier ist die Vorlage: < /p>

Code: Select all

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string",
"defaultValue": "[resourceGroup().name]"
},
"displayName": {
"type": "string",
"defaultValue": "[resourceGroup().name]"
},
"kind": {
"type": "string",
"defaultValue": "azurebot"
},
"region": {
"type": "string",
"defaultValue": "global"
},
"sku": {
"type": "object",
"defaultValue": {
"name": "F0"
}
},
"appType": {
"type": "string",
"defaultValue": "UserAssignedMSI",
"allowedValues": [
"MultiTenant",
"SingleTenant",
"UserAssignedMSI"
]
},
"endpoint": {
"type": "string",
"defaultValue": ""
},
"msaAppId": {
"type": "string",
"defaultValue": ""
},
"msaAppTenantId": {
"type": "string",
"defaultValue": ""
},
"msaAppMSIResourceId": {
"type": "string",
"defaultValue": ""
},
"developerAppInsightKey": {
"type": "string",
"defaultValue": ""
},
"tags": {
"type": "object",
"defaultValue": {},
"metadata": {
"description": "By default the resources will be tagged with the resource group tags. Specify override values or new tags here if needs tags that are different than those of the resource group."
}
}
},
"variables": {
"resourceTags": "[union(resourceGroup().tags, parameters('tags'))]"
},
"resources": [
{
"type": "Microsoft.BotService/botServices",
"name": "[parameters('name')]",
"kind": "[parameters('kind')]",
"apiVersion": "2018-07-12",
"location": "[parameters('region')]",
"sku": "[parameters('sku')]",
"tags": "[variables('resourceTags')]",
"properties": {
"displayName": "[parameters('displayName')]",
"msaAppType": "[parameters('appType')]",
"msaAppId": "[parameters('msaAppId')]",
"msaAppTenantId": "[parameters('msaAppTenantId')]",
"msaAppMSIResourceId": "[parameters('msaAppMSIResourceId')]",
"endpoint": "[parameters('endpoint')]",
"developerAppInsightKey": "[parameters('developerAppInsightKey')]"
}
},
{
"type": "Microsoft.BotService/botServices/channels",
"apiVersion": "2021-05-01-preview",
"name": "[concat(parameters('name'), '/MsTeamsChannel')]",
"location": "global",
"dependsOn": [
"[resourceId('Microsoft.BotService/botServices', parameters('name'))]"
],
"properties": {
"isEnabled": true,
"acceptedTerms": true,
"enableCalling": false,
"deploymentEnvironment": "CommercialDeployment",
"location": "global",
"channelName": "MsTeamsChannel"
}
}
]
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post