OVMS plugin to send telegram messages using bot api
- Open the Telegram app
- Search for the
BotFatheruser - Start a chat with the
BotFatheruser - Send the
/newbotcommand - Follow the instructions to create a new bot
- Copy the token provided by the
BotFatheruser
-
Create a new group in the Telegram app
-
Add the bot you created earlier to the group
-
Send a message to the group
-
Open a new browser tab and go to
https://api.telegram.org/bot<YourBOTToken>/getUpdates(replace<YourBOTToken>with the token you copied earlier) -
Look for the
chatobject and copy theidvalue... "chat": { "id": -123456789, "title": "Hello bot", "type": "group", ...
-
Done! You have the chat ID
- Open the OVMS web interface
- Go to the Tools -> Editor menu item
- Create
/libdirectory in/store/scriptsif it doesn't exist - Create
telegram.jsfile in/store/scripts/libdirectory - Copy the content of the lib/telegram.js file to the
telegram.jsfile you created - Save the file
- Create
ovmsmain.jsfile in/store/scriptsdirectory if it doesn't exist - Copy the content of the ovmsmain.js file to the
ovmsmain.jsfile you created - Save the file
-
Go to the Tools -> Shell menu item in the OVMS web interface
-
Run the following command to set the bot token
config set usr telegram.bot_token <YourBOTToken>Replace
<YourBOTToken>with the token you copied earlier -
Run the following command to set the chat ID
config set usr telegram.chat_id <YourChatID>Replace
<YourChatID>with the chat ID you copied earlier -
Done! The plugin is now configured
- Go to the Tools -> Editor menu item in the OVMS web interface
- Click the Reload JS Engine button
- You should receive a message in the Telegram group you created earlier
script eval "telegram.sendMessage('<message>')"- send a message to the chat groupscript eval telegram.resetConfig()- reset the bot token and chat ID