Umesh Thumar
Umesh Thumar

Reputation: 91

Is there a way to test the locally-hosted bot without Ngrok?

I develop a Microsoft Bot Framework bot and I'd like to test it in Bot Framework Emulator locally without using ngrok. Is there any way?

In the current environment, I am facing proxy related issues and cannot run 'ngrok' in my laptop due to company policies

Thanks for any clues!

Upvotes: 4

Views: 2107

Answers (4)

Kyle Delaney
Kyle Delaney

Reputation: 12284

While the Emulator is a great tool for testing local bots, it serves as its own channel and therefore cannot reliably reproduce channel-specific behavior. Using ngrok you can debug a locally-running bot on any channel. If you want another tunneling service that gives you that same kind of functionality, check out Azure Relays and the Service Bus Relay Util: https://blog.botframework.com/2019/04/16/debugging-your-locally-hosted-v4-bot-using-azure-relays/

Based on your updated question, I don't think Service Bus will solve your problem. You'll probably want to bypass ngrok for local addresses in Emulator.

Upvotes: 2

Jay
Jay

Reputation: 3050

I am going to answer specifically about this part of your question.

I am facing proxy related issues and cannot run 'ngrok' in my laptop due to company policies

So, if they are blocking proxies, and that unfortunately includes the proxy level facilities provided by ngrok, then,

the answer is a simple no. You cannot, in the most simplest form.

My solution (not a technical one, but a pragmatic one, imagining what I would do I your situation) is to get in touch with IT and ask them to lift the restriction.

Alternatively, another solution would be run the bot on another computer, simply for the sake of testing, while keeping your code and development on your company computer.

Again, not a technical solution, but a pragmatic one.

Upvotes: 0

billoverton
billoverton

Reputation: 2885

I'm guessing you may already be using Bot Framework Emulator, which gives you lots of warnings and settings to configure ngrok. But this is not required for local testing! ngrok exposes your local bot on the internet. Unless you have components of your bot that can't access your bot on your local, or you cannot get requests out through your proxy, testing without ngrok works fine.

When you test locally, you just need one generic endpoint in the Emulator with Endpoint URL = http://localhost:3978/api/messages. I name mine "Local Bot" since I use the same configuration for all bot testing. Do not enter the application ID or password. This is what tripped me up for a while; when you're on local you don't need to do this, and it will actually cause your bot not to work if you're not using ngrok.

Now you can just start your bot locally as normal (e.g node index.js for a nodejs bot). If you are behind a proxy, you may need to account for those settings as well. Proxy settings in your console will not work. I recommend setting it in a .env file if you can so your code is not affected. I'm not sure how to do that for C# but for nodejs it's HTTPS_PROXY=http://proxy.company.com:port. I've found that setting HTTP proxy is not necessary and actually breaks my bots.

Upvotes: 1

Mick
Mick

Reputation: 3024

Have a look at the Bot Framework Emulator.

The Bot Framework Emulator is a desktop application that allows bot developers to test and debug bots built using the Bot Framework SDK. You can use the Bot Framework Emulator to test bots running either locally on your machine or connect to bots running remotely through a tunnel.

Upvotes: 0

Related Questions