OfficeDev / TeamsFx

Developer tools for building Teams apps
Other
427 stars 165 forks source link

Bot deployed using Teams Toolkit not working: v5.0.1 #9520

Closed Progressive-Programmer closed 8 months ago

Progressive-Programmer commented 9 months ago

Describe the bug A clear and concise description of what the bug is. Deployed a new bot created from basic bot sample. The bot responds when run in the local. The bot was deployed using Teams Toolkit. The deployed bot is not responding.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error: there is no error message in the bot

Expected behavior The deployed bot should respond.

Screenshots Azure logs Screenshot 2023-08-07 at 12 56 45 AM

Screenshot 2023-08-07 at 12 57 04 AM

VS Code Extension Information (please complete the following information):

CLI Information (please complete the following information):

Additional context This issue was raised with development consultation team originally. It was then suggested by them to raise the issue here as it was their diagnosis that this issue is caused with the new teams toolkit version.

microsoft-github-policy-service[bot] commented 9 months ago

Thank you for contacting us! Any issue or feedback from you is quite important to us. We will do our best to fully respond to your issue as soon as possible. Sometimes additional investigations may be needed, we will usually get back to you within 2 days by adding comments to this issue. Please stay tuned.

Siglud commented 9 months ago

Could you let me know if you're sure you have correctly deployed and started the Azure App Service or Azure Function backend service?

Please use curl or postman request to the backend service API like below:

curl --location 'https://YOUR_AZURE_DOMAIN.azurewebsites.net/api/messages' \
--header 'Content-Type: application/json' \
--data '{}'

If the response is 500 not 4xx, then the App Service is worked. If not, please check the deployment logs at the Azure portal - App Service - Deployment Center - logs - commit ID.

If the backend service is working but you can't get response from the bot service, please try to delete the existing cloud resource and rerun the provision process again.

Progressive-Programmer commented 9 months ago

Deleted these three services and used Teams Toolkit to deploy again Screenshot 2023-08-10 at 1 03 14 PM

Deployment logs commit ID- 2205c9029a. Screenshot 2023-08-10 at 1 08 41 PM

After the deployment tested the curl link: curl --location 'https://appdev46d1a7bot.azurewebsites.net/api/messages' \ --header 'Content-Type: application/json' \ --data '{}'

The curl request is responding 500 Screenshot 2023-08-10 at 1 01 45 PM

BOT ID : e71de7ff-96b0-4a22-bae6-1c0766f1abe0 Error log from bot channels Screenshot 2023-08-10 at 1 11 18 PM Screenshot 2023-08-10 at 1 11 42 PM

Siglud commented 9 months ago

@ Progressive-Programmer Your deployment and App Service are running well. You can add more request handlers like /hello to echo hello world into your index.js or index.ts like below, it will skip the user authentication process to avoid this 500 error and curl the https://[YOUR_DOMAIN]/hello and check the output to verify the deploy status.

server.get("/hello", async (req, res) => {
  res.send("Hello World");
});

And the problem may happen in your Bot Service connecting to App Service or Bot Service connecting to Teams App. For bot service connecting to App Service:

For Teams App connect to Bot Service:

Please tell us which one is not correct in those actions and we can do more investigation.

Progressive-Programmer commented 9 months ago

Sharing my findings: BOT_ID=e71de7ff-96b0-4a22-bae6-1c0766f1abe0

Check your Azure Portal - [Your Bot Service] - Configuration - Microsoft App ID. Make sure it's equal to the BOT_ID in [your project root]/env/.env.[your env name] file. The bot_id matches in both places Screenshot 2023-08-16 at 8 05 27 PM

Check your Azure Portal - [Your App Servicce] - Settings - Environment variables - App Settings. Make sure the BOT_ID and the BOT_PASSWORD are the same as the content in your[your project root]/env/.env.[your env name] and [your project root]/env/.env.[your env name].user file.

I did not find the exact path you shared here: Within Settings menu on the left I didn't see - Environment variables - App Settings. Screenshot 2023-08-16 at 8 21 04 PM

For Teams App connect to Bot Service: The bot id is common in both Screenshot 2023-08-16 at 8 00 11 PM

Screenshot 2023-08-16 at 7 58 39 PM

Siglud commented 9 months ago

Check your Azure Portal - [Your App Servicce] - Settings - Environment variables - App Settings. Make sure the BOT_ID and the BOT_PASSWORD are the same as the content in your[your project root]/env/.env.[your env name] and [your project root]/env/.env.[your env name].user file.

I did not find the exact path you shared here: Within Settings menu on the left I didn't see - Environment variables - App Settings. Screenshot 2023-08-16 at 8 21 04 PM

Most of the snapshot you provided appears to be well-configured. However, the configuration of the Azure App Service is still unclear. That's because I'm using the preview version of the Azure Portal, but you're still in the right place.

Please check the BOT_PASSWARD is correct on this page with your env file of the project. image

Progressive-Programmer commented 9 months ago

BOT_ID & BOT_PASSWORD was not there by default after deployment. I just added it now and restarted the App Service. Checked Web Bot - but it did not respond.

Screenshot 2023-08-17 at 9 43 55 PM

Just to confirm when we run debug mode in local a separate bot_id is generated .env.local has a different bot_id than .env.dev

xzf0587 commented 9 months ago

Hi @Progressive-Programmer The bot_password is set in the .env.dev.user file which keeps the secret env value. You can remove the bot in .env.dev and secret_bot_password in .env.dev.user and try to execute provision again.

image

It seems this project has been upgraded, is that right? Is the project provisioned before upgrade and no provision after upgrade? Also, could you tell me the update/change it has before upgrade?

Siglud commented 9 months ago

Just to confirm when we run debug mode in local a separate bot_id is generated .env.local has a different bot_id than .env.dev

@Progressive-Programmer Yes, they are in different environments, and will not share any provision results.

Progressive-Programmer commented 8 months ago

So,

"It seems this project has been upgraded, is that right? Is the project provisioned before upgrade and no provision after upgrade?" I am not sure what are you referring to by this, can you pls elaborate

Siglud commented 8 months ago
  • then I removed the entire resource and the .env variables associated with it and stared fresh with provision and deployment and the bot still did not respond

@Progressive-Programmer Is the health issue still present after you take this action?

Progressive-Programmer commented 8 months ago

Yes the health issue is still there

Siglud commented 8 months ago

Yes the health issue is still there

@Progressive-Programmer

Did you remove the BOT_ID and BOT_PASSWORD when you deleted the variables in .env? If the BOT_ID & BOT_PASSWARDS exist they will not be created again.

Please try the following actions:

xzf0587 commented 8 months ago

@Progressive-Programmer As the project provision and deployment is successful, please try to use the Launch Remote in debug to check the project.

image

After launched the teams app in browser (Chrome/Edge), open the developer tools by click F12 in browser. Try to trigger the bot request and watch the network request to check the response.

image
xzf0587 commented 8 months ago

"It seems this project has been upgraded, is that right? Is the project provisioned before upgrade and no provision after upgrade?" I am not sure what are you referring to by this, can you pls elaborate

I found the key pattern in .env.dev and there is a .backup folder in project. It shows it is a upgraded project from v4.

image
microsoft-github-policy-service[bot] commented 8 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

microsoft-github-policy-service[bot] commented 8 months ago

Due to lack of details for further investigation, we will archive the issue for now. In case you still have following-up questions on this issue, please always feel free to reopen the issue by clicking ‘reopen issue’ button below the comment box. We will get back to you as soon as possible.