Notification System with WVMS: Leveraging Telegram

Notification System with WVMS: Leveraging Telegram

Notification System with WVMS: Leveraging Telegram

Integrating notification systems with video management systems (VMS) has always been in high demand. It is crucial to receive alerts for events such as alarms or camera failures, as relying solely on live operators can be insufficient. While traditional methods like emails and text messages are commonly used, modern approaches are gaining popularity. One such trending messenger is WhatsApp, but its API is closed and comes with a significant cost. However, there are alternative options to explore, such as Telegram. Telegram offers an open and robust API, ensuring both security and versatility. Now, let’s delve into the practical implementation of integrating Telegram with your VMS.

Telegram is a messaging app that has gained popularity among both personal and business users. One of its key advantages is that it doesn’t share your messages with Facebook’s targeted advertisements. It offers a range of client options, including web, mobile, and desktop, making it convenient for users. Many people choose Telegram for its safety features, although it’s important to note that the security relies on the servers it uses, which is the case with any messaging platform. Telegram has a growing audience and an increasing amount of media content, allowing users to chat, read news, share files, and even engage in video chats within the app.

To get started with Telegram, begin by installing your preferred client. The easiest option is to use the web version available at https://web.telegram.org/. For enhanced mobility, you can download the Android or iOS app. Additionally, there are dedicated desktop clients for Windows, Mac, and Linux
operating systems.

On the server side of your WVMS system, make sure you have the latest WVMS version installed. Starting from version 1.21, WVMS supports HTTPS, as Telegram does not accept plain HTTP
connections due to security considerations.

Now that everything is set up, let’s proceed to the first step: creating a bot.

Bot Creation

To get started, open your Telegram app and search for “@BotFather” – this is the username of the bot you’ll interact with. Once you’ve found him, initiate a chat with him. To create a new bot, simply type “/newbot” and follow the instructions provided by BotFather.

In the same chat window, you have the option to modify the settings of your bot, such as setting a profile picture and adding commands. However, at this stage, the most crucial piece of information you need is the API token provided by BotFather. This token is necessary for making requests to the
Telegram API.

Important: Keep your bot token secure and confidential! If the token falls into the wrong hands, it can grant complete control over your bot. If you suspect that your token has been compromised, contact BotFather and ask him to revoke the current token. Remember, as an IT administrator, it’s essential to
prioritize security.

Once you have obtained the API token, you can start sending messages to yourself using the bot you just created.

Configure the Bot

To interact with the Telegram API and send messages, you need to follow a specific format for your requests. All API queries must be served over HTTPS and adhere to the following structure:

https://api.telegram.org/bot/

Example:

https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getUpdates

(Note: The above API token is just a dummy example from Telegram’s API description.)

To send a direct message to a user, you first need to obtain their chat ID. As a security measure, bots cannot initiate chats, so you’ll need the user to send a message to your bot first.

If you are the recipient of the message, you can find your chat ID by using bots like “@userinfobot,” “@RawDataBot,” or searching for similar bots online.

Once you have the chat ID, you can form a URL to send a message to your bot using the following format:

https://api.telegram.org/bot/sendMessage?chat_id=&text

In the URL:

represents your bot token.

• SendMessage is the Telegram API method for sending messages.

is the identifier of the target user or channel.

is the content of the message you want to send.

You can test the request by copying the URL into your browser’s address bar. If the message is sent successfully, the browser window will display output starting with “OK:true” followed by any relevant result parameters. If you encounter a 404 or similar error, double-check the URL and try again.

Following these guidelines, you can establish a message flow from Wavesys WVMS to your Telegram bot. Enjoy the seamless communication!

Broadcasting

When it comes to delivering messages to multiple recipients, Telegram offers two options: channels and groups. Each has its own advantages and considerations, so you can choose the one that best suits your needs.

Channels are ideal for passive broadcasting to a large audience, potentially reaching an unlimited number of users. They are designed for one-way communication, making them suitable for CCTV alert Configure WVMS broadcasts or other announcements. You can create private channels to ensure privacy for sensitive information.

Groups, on the other hand, allow all members to post messages, facilitating discussions and interactions among participants. While this enables collaboration, it also means that all users within the group can see each other’s messages and identities.

You have the freedom to create any number of private or public channels, keeping in mind that anyone can join a public channel. Consider creating separate private channels for different teams or
departments within your organization. For example, you can have a private channel for IT personnel and another one for company managers. In both cases, you can add your bot as an admin and grant it permission to post messages. For groups, simply invite your bot as a regular user, and it can participate in the conversation like any other member.

By carefully choosing between channels and groups and configuring the appropriate settings, you can effectively deliver messages to the desired audience within your organization using Telegram.

Configure WVMS

To integrate the message sending functionality into Wavesys WVMS, you will utilize the Event & Action Configurator, which is responsible for automation tasks. By adding a new action of the “Send HTTP Request” type and providing the required information, you can easily configure the message content
and target.

When constructing your message, you can include event-related values depending on the specific use case and the event that triggered the action. These values can be passed as arguments in the message using macros. For example, if the action is triggered by a recognition event, you can include macros such as {ADDITION_INFORMATION:Plate} for the recognized license plate in LPR events, {ADDITION_INFORMATION:Subject} for the recognized subject name in facial recognition events, or {ADDITION_INFORMATION:Tag} for the item tag if available.

To access the available macros, you can right-click the text box or use the “Insert field” button, which will provide a list of variables based on the event type. For example, {EVENT_SOURCE_ID} represents the internal identifier of the target channel, and {EVENT_SOURCE_TITLE} corresponds to the channel
name. For other event sources like user buttons, doors, or servers, relevant names will be reflected accordingly.

Once you have defined the action and configured the message content, you can proceed to build a rule using the action, as you would normally do in Wavesys WVMS. To ensure that the action is working correctly, you can use the “Test” button in the Rules tab, which will execute the action and provide an execution report in the Audit Log section under Servers. If you encounter any issues, you can utilize tools like Wireshark to investigate further details, especially if the HTTP response is not successful.

By following these steps, you can effectively incorporate message sending capabilities into Wavesys WVMS using the Event & Action Configurator, enhancing automation and alerting within the system.

Configuring Video

To include a live video stream link in your message from WVMS, you will need to construct an API link using the following format:

http://[WVMS_server_IP]:[WVMS_HTTP_port]/publicLive/[channel_ID]/mainStream. For added security, ensure that HTTPS is enabled and configured on the WVMS server, and use the following format instead:

https://[WVMS_server_IP]:[WVMS_HTTPS_port]/publicLive/[channel_ID]/mainStream.

During the configuration phase, it is recommended to use plain HTTP to view the request and Telegram response using tools like Wireshark. Once the message delivery is confirmed, you can switch to HTTPS before finalizing the setup for improved security.

Here is an example of a cURL command within the executable file, which includes plain text, a channel URL, and a parameter (%1 in this example):

curl -X POST -d “chat_id=%1&text=Check out the live video stream [insert_channel_URL_here]”
https://api.telegram.org/bot[TOKEN]/sendMessage

With cURL, you can enclose the entire request within quotation marks and freely use spaces and special characters.

In the action configuration, you can use {EVENT_SOURCE_ID} as an argument (%1 in this example, assuming you’re using a batch file). If you’re utilizing a different scripting language, refer to its
instructions on how to pass parameters.

By combining this action with events of your choice in your WVMS server, such as motion events, triggered analytics, opened doors, or customer transactions, you can trigger the message delivery to
your Telegram client. Additionally, you can dispatch multiple actions based on a single event for
enhanced automation and alerting capabilities.

Granting Permissions

To ensure that you and other recipients can access the live video stream link, you need to grant the necessary permissions. Follow these steps:

1. Open the Permissions settings for your target channel.

2. Locate the user named “Anonymous” in the user list.

3. Assign the “View live video” permission to the “Anonymous” user.

By granting this permission, you enable yourself and anyone you share the link with to view the live video stream from the channel. You now know how to setup notifications on Telegram!

No Comments

Sorry, the comment form is closed at this time.