microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.47k stars 2.44k forks source link

Unable to send message via rest API #6590

Closed atkawa7 closed 1 year ago

atkawa7 commented 1 year ago

Problems with sending Messages to Skype bot

I have a bot that I have been using of late. So I went back to dev.botframework.com/bots.

My bot is currently configured for a single tenant and registered with custom directory under app registrations. For now I am able to obtain an access token via

{
    "correlation": "cd814ac5b710b657",
    "request": {
        "origin": "local",
        "protocol": "HTTP/1.1",
        "remote": "localhost",
        "method": "POST",
        "uri": "https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token",
        "host": "login.microsoftonline.com",
        "path": "/<tenant_id>/oauth2/v2.0/token",
        "scheme": "https",
        "port": null,
        "headers": {
            "Accept": [
                "application/json"
            ],
            "Content-Type": [
                "application/x-www-form-urlencoded;charset=UTF-8"
            ]
        },
        "body": "client_id=<client_id>&client_secret=XXX&grant_type=client_credentials&scope=https%3A%2F%2Fapi.botframework.com%2F.default"
    },
    "response": {
        "origin": "remote",
        "duration": 1959,
        "protocol": "HTTP/1.1",
        "status": 200,
        "headers": {
            "Cache-Control": [
                "no-store, no-cache"
            ],
            "Content-Length": [
                "1581"
            ],
            "Content-Type": [
                "application/json; charset=utf-8"
            ],
            "Date": [
                "Fri, 14 Apr 2023 10:01:25 GMT"
            ],
            "Expires": [
                "-1"
            ],
            "P3P": [
                "CP=\"DSP CUR OTPi IND OTRi ONL FIN\""
            ],
            "Pragma": [
                "no-cache"
            ],
            "Set-Cookie": [
                "fpc=AtyiuAy0FTVEnGEveFNh8oTRAE4bAQAAAHUby9sOAAAA; expires=Sun, 14-May-2023 10:01:26 GMT; path=/; secure; HttpOnly; SameSite=None",
                "x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly",
                "stsservicecookie=estsfd; path=/; secure; samesite=none; httponly"
            ],
            "Strict-Transport-Security": [
                "max-age=31536000; includeSubDomains"
            ],
            "X-Content-Type-Options": [
                "nosniff"
            ],
            "x-ms-ests-server": [
                "2.1.15049.5 - EUS ProdSlices"
            ],
            "x-ms-request-id": [
                "84c9907c-9059-405b-930e-ee6e014d1200"
            ],
            "X-XSS-Protection": [
                "0"
            ]
        },
        "body": "{\"token_type\":\"Bearer\",\"expires_in\":3599,\"ext_expires_in\":3599,\"access_token\":\"XXX\"}"
    }
}

I am getting notifications to the endpoint configured. However responding fails for the skype channel.


{
    "response": {
        "origin": "remote",
        "duration": 1963,
        "protocol": "HTTP/1.1",
        "status": 401,
        "headers": {
            "Content-Length": [
                "61"
            ],
            "Content-Type": [
                "application/json; charset=utf-8"
            ],
            "Date": [
                "Fri, 14 Apr 2023 12:12:21 GMT"
            ],
            "Server": [
                "Microsoft-HTTPAPI/2.0"
            ]
        },
        "body": "{\"message\":\"Authorization has been denied for this request.\"}"
    },
    "correlation": "e5d4e795873fc8e9",
    "request": {
        "origin": "local",
        "protocol": "HTTP/1.1",
        "remote": "localhost",
        "method": "PUT",
        "uri": "https://smba.trafficmanager.net/apis/v3/conversations/<converationId>/activities/<activityId>",
        "host": "smba.trafficmanager.net",
        "path": "/apis/v3/conversations/<converationId>/activities/<activityId>",
        "scheme": "https",
        "port": null,
        "headers": {
            "Accept": [
                "application/json"
            ],
            "Authorization": [
                "Bearer <JWT Token>"
            ],
            "Content-Type": [
                "application/json"
            ]
        },
        "body": {
            "from": {
                "id": "<bot_id>",
                "name": "<bot_name>"
            },
            "recipient": {
                "id": "<account_id>",
                "name": "<account_name>"
            },
            "replyToId": "<activityId>",
            "text": "Text to send",
            "textFormat": "plain",
            "type": "message"
        }
    }
}
dmvtech commented 1 year ago

Hi @atkawa7

Is this a bot that has been created for some time and was connected to the Skype channel? Was it created in the dev.botframework.com/bots portal?

atkawa7 commented 1 year ago

@dmvtech yes that's correct.

dmvtech commented 1 year ago

Hi @atkawa7

Apologies for the delay. Are you able to get a simple echo bot working locally (using ngrok) in the Skype channel with that same bot registration?

dmvtech commented 1 year ago

Hi @atkawa7 Do you still need assistance with this issue?

atkawa7 commented 1 year ago

@dmvtech Reolved by making it multitenant