This article shows you how to build an interactive price quoting application over Telegram in Node.js. The application responds to user’s requests for price quotes interactively. Don’t know what I am talking about? The following screenshot should explain it more clearly:
- You need an Enterprise Telegram Gateway API account with WhatsMate.
- You have access to a Linux (such as Ubuntu) machine.
- Your machine has Node.js and npm installed.
- Download the source code package. Alternatively, you can clone the demo repository if you use git.
- Customize the Node.js script
enterprise-demo-app2.jswith your account settings on lines 37-43.
- Run your application:
If you are new to Node.js and want to understand how the Node.js script
enterprise-demo-app2.js works, we are here to help:
- Lines 3-5 include the required dependent libraries.
- Lines 47-48 create the
expressweb framework instance.
- Lines 104-112 define the behavior of the webhook. That is, it determines the webhook endpoint and what to do when it receives a Telegram message from a user. It delegates the handling to the function
- Lines 115-120 kick start the
expressweb application server so that it listens on the specified port for incoming webhook events.
- Lines 51-75 are the gist of the application. You define how you want to respond to your user’s messages here. The sample program implements a simplistic price quoting engine. Feel free to change it to fit your own needs.
- Lines 78-101 define the utility function
sendTelegramMessage. Its name already tells you what it does. You don’t need to change it.
If you are keen to implement an automated interactive application that talks to your users on Telegram, get in touch with one of our technical representatives to sign up for an Enterprise account now.
Want to look at other innovative ideas? Check out the interesting use cases page.
- We are not affiliated with Telegram in any way. We only provide a gateway for sending out and receiving Telegram messages. We cannot guaranttee the gateway is functional at all times.