Introduction

Getting started with webhooks

the fastest way to connect a service or application with kindly is using our webhooks webhooks can be added to any dialogue or fallback, and are simply sent via a post https //developer mozilla org/en us/docs/web/http/methods/post request by the kindly backend to the predefined url for a complete reference on webhooks see the webhooks reference docid\ ot0nvuq i76ze m5vrvuc how to use there are multiple steps to follow for setting up a successful webhook set up a simple web server for this example, we'll set up and use our own web server to post to our server will have a single endpoint, that simply returns a message to our bot python the example server below is running python through flask http //flask pocoo org/ upon receiving the webhook payload, the server will respond by returning a simple message from flask import flask, jsonify app = flask( name ) @app route('/kindly', methods=\['post']) def get() response = { 'reply' 'hello from server!', } return jsonify(response) when running the script above, the server will run on localhost, with port 9000 node the example server below is running on hapi https //hapijs com/ upon receiving the webhook payload, the server will respond by returning a simple message const hapi = require("@hapi/hapi"); const server = hapi server({ host "0 0 0 0", port 9000, }); server route({ method "post", path "/kindly", handler ( request, h) => ({ reply "hello from server!", }), }); server start(); when running the script above, the server will run on localhost, with port 9000 set up ngrok to test our newly configured server, we'll need to serve the script through ngrok https //ngrok com/download ngrok is necessary for kindly to communicate with our development machine (localhost), using it makes it a lot faster to develop, test and prototype new integrations and webhooks follow the link above to set up ngrok on your machine when ngrok is set up, we need to point it to the port on which our server is running this can be acheived with the following command /ngrok http 9000 note that this needs to be done inside the folder you installed ngrok if the command is successful, something similar to the following will be visible in our terminal session status online account bob bobsen (plan free) version 2 2 8 region united states (us) web interface http //127 0 0 1 4040 forwarding http //725a9731 ngrok io > localhost 9000 forwarding https //725a9731 ngrok io > localhost 9000 connections ttl opn rt1 rt5 p50 p90 0 0 0 00 0 00 0 00 0 00 create a new dialogue when our server is set up, and ngrok is running, we need to create a new dialogue and paste in the address we want to post to in the build section, navigate to a dialogue, then output , and under advanced features paste in the address ngrok provided in my case, i would paste in http //725a9731 ngrok io be sure to include the endpoint path in the url which we used in our server /kindly to get the correct response trigger webhook now we're ready to test our webhook through the chat bubble, by triggering the dialogue we created earlier if everything is set up correctly, the bot will respond with our message inspect response when the dialogue is triggered, and the response is received, we can inspect the response in the debug console the object created in the console will give us a detailed overview of the payload sent, and received examples check out example chat transcript webhook docid\ tcfg52zbqm7 oyque5raj for a complete webhook app