Illustration with a yellow cookie.
We are using cookies

This website uses cookies and other tracking tools to improve the user experience, display customized content and ads, analyze website traffic, and determine the source of traffic.

Start building AI chatbots and email bots with Amio.

Book a 30-minute session where we will find out how AI bot can help you decrease call center costs, increase online conversion, and improve customer experience.

Book a demo
BlogChatbots

Chatbot's Diary: Webhooks on Localhost

March 7, 2022
February 12, 2024
Graphic - Webhooks on Localhost

There was one thing that always annoyed me when developing chatbots. It was webhooks. Messengers like Facebook, Viber or us (Amio) intent to push messages to your endpoint. However, the messengers can't reach your app when you specify the webhook URL as localhost.

graphic - Amio Webhooks

Of course, you can test your code on a remote machine. But you have to deploy the app to an internet facing server every time you make a change in the code. That's very time-consuming, especially when you only make a tiny change. Fortunately, there is a way how to let others reach your local machine.

Localhost tunneling

To test webhooks on the local machine, you need to tunnel localhost so that it gets a public URL. You can do it by yourself but it ain't that simple. With my favorite tools ngrok or localtunnel (I use just as a backup) you're ready in a minute and you can start receiving the events.

Graphic - Amio Webhooks 2

Ngrok setup

  1. Run your app on a port of your choice, for example 8080.
  2. Setup ngrok.
  3. In command line, execute ngrok http 8080. Ngrok will create a public facing url and tunnel it to your localhost. You'll see a similar screen:
image ngrok setup

Time to test

After configuring the localhost tunneling, you surely want to try it out. The simplest way is to open your browser and paste the tunneled URL (http://529081d6.ngrok.io in our case). Then go to ngrok web interface http://127.0.0.1:4040 and observe what happened. The best thing for development is that you can explore the content of a request. You'll probably see a similar picture:

Image - ngrok web testing

Farewell

You've just made your programming life simpler. If you're developing a chatbot or a messaging app, Amio will speed up your project. Give it a try! It's free.

Happy coding! ;-)

Table of Contents
1
Quick Link
Article by:
Matous Kucera

Matous is a co-founder of Amio. As a software engineer, he built several profitable businesses. Now, he is helping e-commerce businesses to get most out of chatbots and email bots.

We understand your business on

Book a 30-min consultation session where we will discuss your support cost optimization potential, experience improvements, including our online conversion increase techniques

Start free