Friday, September 13, 2019

Troubleshooting CyBot on Microsoft Teams

By Tony Lee

This is a follow-on article to hopefully help address any questions or errors that you may encounter while following our previous article (http://securitysynapse.blogspot.com/2019/09/cybot-on-microsoft-teams.html) on setting up Errbot and CyBot on Microsoft Teams. We will cover both a quick Botnet Framework Emulator section as well as a Quick Q&A at the bottom of the article.

Troubleshooting using Botnet Framework Emulator

If you are having issues getting the Azure Web Chat working or any other step in the process, it may be helpful to troubleshoot using the Botnet Framework Emulator. The github project is free and can be found here:
https://github.com/Microsoft/BotFramework-Emulator

Follow the documentation for install and setup found here:
https://github.com/Microsoft/BotFramework-Emulator/wiki

Note: Since this is a remote bot, ngrok will be required to tunnel the traffic off of the localhost. Ngrok will work for a period of time as a free trial. After that, you can still use it for free, but you will need to sign up for a free account and enter an authorization token.

To configure ngrok go here:
https://github.com/microsoft/BotFramework-Emulator/wiki/Tunneling-%28ngrok%29

Once downloaded, installed, and ngrok is configured.  Connect to your bot to test. First try unencrypted communications to rule out SSL issues being the cause of failure.

Figure 1:  Initial configuration using HTTP

Figure 2:  HTTP traffic works!


Then try to use HTTPS in the Botnet Framework Emulator to ensure it works over SSL. If this is the case, you should be able to get Microsoft Teams to communicate with the bot.


Figure 3:  HTTPS works.  Now try the Teams client!


Quick Questions and Answers

These are questions and issues we ran into while setting up the bot. They could help you too:

Q:  I cannot get this working using the free Azure bot services
A:  We couldn’t either, despite the information on Microsoft’s website.  Sign up for a Pay-As-You-Go subscription and it does not appear to use any resources so it should still be free.

Q: "Test in Web Chat" is not working
A: Go to Bot management > Channels > Click on Issues (under health)
A: If this does not provide enough information, troubleshoot using the Bot Framwork Emulator + ngrok

Q: The Azure Bot management > Channels error message reads:  "There was an error sending this message to your bot: HTTP status code Unauthorized"
A: Ensure your appID and appPassword are correct.  If so, make sure the Azure Portal is not trying to connect directly to errbot. You need to proxy the traffic through nginx.  Traffic flow will look like:  Azure -> nginx:443 -> errbot:80

Q: I get this error message when trying to run errbot:  "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)”
A: Don't place the Botframework in the plugins directory, instead place it in ~/errbot-root

Q: I can't figure out the Azure Portal process without pictures

Q: Microsoft Bot Channels Registration automatically created the appPassword and I cannot access it
A: Create a new appPassword from Dashboard > <Your Bot> > Settings > “Manage” hyperlink > Client secrets > New

Q: The appId under settings is grayed out and I cannot copy it
A: Obtain the appId under Overview "Application (client) ID"


Conclusion

We hope this article helps with any troubleshooting efforts. If not, feel free to post your question(s) below or hit us up on LinkedIn. Thanks for reading!

2 comments:

  1. Thanks for the quick post. As always, amazing work Tony.

    ReplyDelete