Coder Social home page Coder Social logo

Direct Line App Service Extension does not work with Azure bot created with Virtual Assistant Template about botframework-solutions HOT 17 CLOSED

pravinambekar avatar pravinambekar commented on May 24, 2024
Direct Line App Service Extension does not work with Azure bot created with Virtual Assistant Template

from botframework-solutions.

Comments (17)

YutongTie-MSFT avatar YutongTie-MSFT commented on May 24, 2024 2

@dmvtech Hi Dana, I am tracking this issue from Microsoft Q&A platform. Could you please help take a look? Thanks.

from botframework-solutions.

dmvtech avatar dmvtech commented on May 24, 2024 2

I will take a look.

from botframework-solutions.

SSanjeevi avatar SSanjeevi commented on May 24, 2024 1

Is that error coming in log stream console? - may be you missed this second line I think not sure:

services.AddSingleton<IBotFrameworkHttpAdapter, DefaultAdapter>(); services.AddSingleton<BotAdapter>(sp => sp.GetService<BotFrameworkHttpAdapter>());

for webchat - I done basic implementation - token you can do after this works.

from botframework-solutions.

pravinambekar avatar pravinambekar commented on May 24, 2024 1

Is your /xxx.azurewebsites.net/.bot URL works? please check connecting from webchat client.

Hi @pravinambekar

Looks like you've made some progress. Some additional questions:

  1. I'm assuming since this is a VA bot that it is using BotFrameworkAdapter and not the newer CloudAdapter, correct?
  2. You have correctly set APPSETTING_WEBSITE_SITE_NAME in the configuration?
  3. When setting your secret for the bearer token, you are using the actual Directline secret (even though it is posting to your ASE generate endpoint) and not the Directline ASE secret, correct?
  4. Can you clarify on:

but while testing it from web chat client i am getting Failed to fetch error (chat.html:49 TypeError: Failed to fetch)

What is on line 49? Checking the console per @SSanjeevi is a great idea.

Hello @dmvtech , Hello @SSanjeevi ,

  1. Yes VA bot that it is using BotFrameworkAdapter and not Cloud Adapter
  2. Yes APPSETTING_WEBSITE_SITE_NAME is correctly configured
  3. Yes The secrete used for token generated in Direct Line Secrete and not ASE secrete

About the error in console , I dig down further and found that the timeout is happening upon calling token generation service : https://XXX.azurewebsites.net/api/directline/token, i am yet to find reason why timeout is happening
but meanwhile i tried skipping token call (Just for Test purpose) and directly provided Direct Line secrete as token to renderWebChat() method and could see Web chat rendered successfully.

image

Few concerns still to address :

  1. Adaptive card attachment does not work directly
  2. Refresh token logic

Do you have any idea why request token gets timeout, is this related to app service hosted environment or plan ?

from botframework-solutions.

pravinambekar avatar pravinambekar commented on May 24, 2024 1

Not sure about issue when using the token. What I analyzed(understood) is that its using WebSocket connection to connect between client and server using ASE - not sure whether we can create token before that socket connection is established - @dmvtech and team will help you on that.

Hello @SSanjeevi , @dmvtech

I think i found the culprit, the url we use for token generation has to be : https://XXX.azurewebsites.net/.bot/v3/directline/tokens/generate and not
https://XXX.azurewebsites.net/api/directline/token/generate

It was my bad.

from botframework-solutions.

SSanjeevi avatar SSanjeevi commented on May 24, 2024 1

please close the issue - if its resolved 🥇 happy to help.

from botframework-solutions.

pravinambekar avatar pravinambekar commented on May 24, 2024 1

Thanks @SSanjeevi & @dmvtech for your help.

from botframework-solutions.

pravinambekar avatar pravinambekar commented on May 24, 2024

I will take a look.
@dmvtech Hello Dana,
Did you got time to look into this, i really failed to understand root cause for the issue, at one side Test In Web chat works fine,
i have a feeling that there is some issue with the way client side request is communicating with bot over direct line and the definition for createDirectLineAppServiceExtension function defined in botframework-webchat js
as the constant error : WebSocket connection to XXX failed. is there and there is literally nothing i could fix about this.
image

Moreover calls to https://directline.botframework.com/v3/directline/conversations working fine in Postman, it means secrete and bot app is correctly configured.
And even the client side code is simple and as per Bot Framework documentation.
index.txt

another question : The token i generated have issuer and Audience as :
"iss": "https://directline.botframework.com/",
"aud": "https://directline.botframework.com/"

Where as documentation from: https://github.com/microsoft/BotFramework-WebChat/tree/main/samples/01.getting-started/i.protocol-direct-line-app-service-extension says it should be :
The token is a JSON Web Token and the iss and aud fields are both https://directlineextension.botframework.com/
https://directlinextension.botframework.com

Does that make any difference,, if yes, how can we get directlineextension as iss and aud ?

It would be really helpful if get cause for the issue.
Thank you again.

from botframework-solutions.

pravinambekar avatar pravinambekar commented on May 24, 2024

I will take a look.
@dmvtech Hello Dana,
Did you got time to look into this, i really failed to understand root cause for the issue, at one side Test In Web chat works fine,
i have a feeling that there is some issue with the way client side request is communicating with bot over direct line and the definition for createDirectLineAppServiceExtension function defined in botframework-webchat js
as the constant error : WebSocket connection to XXX failed. is there and there is literally nothing i could fix about this.
image

Moreover calls to https://directline.botframework.com/v3/directline/conversations working fine in Postman, it means secrete and bot app is correctly configured. And even the client side code is simple and as per Bot Framework documentation. index.txt

another question : The token i generated have issuer and Audience as : "iss": "https://directline.botframework.com/", "aud": "https://directline.botframework.com/"

Where as documentation from: https://github.com/microsoft/BotFramework-WebChat/tree/main/samples/01.getting-started/i.protocol-direct-line-app-service-extension says it should be : The token is a JSON Web Token and the iss and aud fields are both https://directlineextension.botframework.com/ https://directlinextension.botframework.com

Does that make any difference,, if yes, how can we get directlineextension as iss and aud ?

It would be really helpful if get cause for the issue. Thank you again.

---------------Update-----------------------

I continued investigation and have tried to generate token from my own app service url (https://xxx.azurewebsites.net/.bot/v3/directline/tokens/generate) in token controller but the call returns null or empty token
image
and when i check log in portal i am getting 404 error for the service call :
image

Could you please suggest why i am getting 404. ?

from botframework-solutions.

SSanjeevi avatar SSanjeevi commented on May 24, 2024

@pravinambekar - I have tried the same and it seems to be working - please refer my repo with complete sample, if you see any issues let me know :
https://github.com/SSanjeevi/VirtualAssistantDirectlineExtn

You can check the app service log stream window when accessing the webchat, you will see the logs if you see any issue - by following my repo code for serilog logging.

from botframework-solutions.

pravinambekar avatar pravinambekar commented on May 24, 2024

@pravinambekar - I have tried the same and it seems to be working - please refer my repo with complete sample, if you see any issues let me know : https://github.com/SSanjeevi/VirtualAssistantDirectlineExtn

You can check the app service log stream window when accessing the webchat, you will see the logs if you see any issue - by following my repo code for serilog logging.

Hello @SSanjeevi ,

Thank you for sharing repo, while checking your source i am getting serilog error as below :

[ERR] Some services are not able to be constructed 
(Error while validating the service descriptor 'ServiceType: Microsoft.Bot.Builder.Integration.IAdapterIntegration 
Lifetime: Singleton ImplementationType: VirtualAssistantSample.Adapters.DefaultAdapter': 
Unable to resolve service for type 'Microsoft.Bot.Connector.Authentication.AuthenticationConfiguration' 
while attempting to activate 'VirtualAssistantSample.Adapters.DefaultAdapter'.) 
(Error while validating the service descriptor 'ServiceType: Microsoft.Bot.Builder.Integration.AspNet.Core.IBotFrameworkHttpAdapter 
Lifetime: Singleton ImplementationType: VirtualAssistantSample.Adapters.DefaultAdapter': 
Unable to resolve service for type 'Microsoft.Bot.Connector.Authentication.AuthenticationConfiguration' 
while attempting to activate 'VirtualAssistantSample.Adapters.DefaultAdapter'.) 
(Error while validating the service descriptor 'ServiceType: Microsoft.Bot.Builder.ChannelServiceHandler 
Lifetime: Singleton ImplementationType: VirtualAssistantSample.TokenExchange.TokenExchangeSkillHandler': 
Unable to resolve service for type 'Microsoft.Bot.Solutions.Skills.SkillsConfiguration' 
while attempting to activate 'VirtualAssistantSample.TokenExchange.TokenExchangeSkillHandler'.)   
at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable`1 serviceDescriptors, ServiceProviderOptions options)

Is this related to version issue ? i have seen similar error you reported on SO, but the thread seems not have concrete soultion, may be you could help here. (while i will keep on investigating)

additionally I am bit concerned with the way client code is implemented, here we are directly exposing Direct Line Secret.
which is suppose to be generate in separate api controller
image

Do you have any suggestion over the error i am getting during DI, may be token part we can take care in controller

Regards,
Pravin

from botframework-solutions.

pravinambekar avatar pravinambekar commented on May 24, 2024

Is that error coming in log stream console? - may be you missed this second line I think not sure:

services.AddSingleton<IBotFrameworkHttpAdapter, DefaultAdapter>(); services.AddSingleton<BotAdapter>(sp => sp.GetService<BotFrameworkHttpAdapter>());

for webchat - I done basic implementation - token you can do after this works.

Hello @SSanjeevi ,
I was able to run bot locally but i guess there is some issue with running bot on local IIS (getting timeout when run on local iis but was able to run on console)
In spite of that i deployed bot and related services on azure but getting 502 error upon access app service.

ModuleName	AspNetCoreModuleV2
Notification	EXECUTE_REQUEST_HANDLER
HttpStatus	502
HttpReason	Bad Gateway
HttpSubStatus	5
ErrorCode	The app didn't start in the required time. (0x8027025a)

Do you have any idea what possibly could go wrong ? I guess something is wrong with IIS configuration, or the way app is running on IIS

from botframework-solutions.

SSanjeevi avatar SSanjeevi commented on May 24, 2024

Is your /xxx.azurewebsites.net/.bot URL works?
please check connecting from webchat client.

from botframework-solutions.

pravinambekar avatar pravinambekar commented on May 24, 2024

Is your /xxx.azurewebsites.net/.bot URL works? please check connecting from webchat client.

Hi @SSanjeevi ,
The https:/xxx.azurewebsites.net/.bot is now returning json response :
{
v: "1.0.0.0.55fa54091a1e3b168628d4000ee2b06a88bbc2ac",
k: true,
ib: true,
ob: true,
initialized: true
}

but while testing it from web chat client i am getting Failed to fetch error

chat.html:49 TypeError: Failed to fetch
    at chat.html:34:27
    at chat.html:49:9

from botframework-solutions.

SSanjeevi avatar SSanjeevi commented on May 24, 2024

check browser console - net work tab - you may have to check that and restart app service and enable socket.

from botframework-solutions.

dmvtech avatar dmvtech commented on May 24, 2024

Hi @pravinambekar

Looks like you've made some progress. Some additional questions:

  1. I'm assuming since this is a VA bot that it is using BotFrameworkAdapter and not the newer CloudAdapter, correct?
  2. You have correctly set APPSETTING_WEBSITE_SITE_NAME in the configuration?
  3. When setting your secret for the bearer token, you are using the actual Directline secret (even though it is posting to your ASE generate endpoint) and not the Directline ASE secret, correct?
  4. Can you clarify on:

but while testing it from web chat client i am getting Failed to fetch error (chat.html:49 TypeError: Failed to fetch)

What is on line 49? Checking the console per @SSanjeevi is a great idea.

from botframework-solutions.

SSanjeevi avatar SSanjeevi commented on May 24, 2024

@pravinambekar - thanks for confirming that bot works when using secret in webchat.
Not sure about issue when using the token. What I analyzed(understood) is that its using WebSocket connection to connect between client and server using ASE - not sure whether we can create token before that socket connection is established - @dmvtech and team will help you on that.

from botframework-solutions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.