send Telegram notifications with pictures

tms5d

n3wb
Joined
Mar 23, 2015
Messages
4
Reaction score
1

bp2008

Staff member
Joined
Mar 10, 2014
Messages
10,059
Reaction score
7,648
Location
USA
I glanced at their API documentation but it doesn't seem like they support sending images. Even if they did it is unlikely that Blue Iris would support sending images to them anyway.
 

tms5d

n3wb
Joined
Mar 23, 2015
Messages
4
Reaction score
1
So, this is how far I got until now:

- I wrote this BASh-script (lines after # not active yet) called achterom.sh (achterom = backyard in Dutch ;-)



- which I put in a .bat-file called achterom.bat like this:


Have a look at How to Create and Run Bash Shell Scripts on Windows 10 for more information on how to run bash-scripts on a Windows platform.


- the achterom.bat-file is then executed from 'Alerts'--> 'Run a program or execute a script' like this:




When I push "Test", it works like a charm, I get a Telegram-notification plus image which I pull directly from one of my Hikvision camera's (the 'wget -O $SnapFile1 ....'-line from the bash-script ).

This is what I see in Telegram after pushing the 'configure run alert' -'TEST'-button in Blue Iris (expected behaviour):



After pushing the 'configure run alert' --> 'OK' button however, I do NOT get a Telegram-notification at all when motion is detected, (which is unexpected because it works when I pushed the TEST button).

Blue Iris service is running as Admin by the way (because of Cam trigger sends text message, but does not run a script)




Until, now, I have not been able to figure out why everything does work as expected (telegram notification plus image) when hitting the TEST button, but not when motion is detected (no telegram notification at all). Any help would be really appreciated!!
 
Last edited:

bp2008

Staff member
Joined
Mar 10, 2014
Messages
10,059
Reaction score
7,648
Location
USA
I don't see a reason why the behavior would be any different. Can you inspect the network traffic with a program like Fiddler? That might indicate where the problem is.
 

GentlePumpkin

IPCT Contributor
Joined
Sep 4, 2017
Messages
146
Reaction score
218
Another option is to use the etlgr.com @etlgr_bot bot for telegram. You assign an email address, send the picture or video to it via BI email notification and etlgr forwards this email to telegram. You then might want to configure that you only see the attached image and not the subject, sender etc, buts thats easily done by changing the message format to "%{}" (without the " of course :)).

Works very well im my opinion, but one should keep in mind that etlgr could access the images.
 

Sascha S

n3wb
Joined
Sep 25, 2019
Messages
1
Reaction score
0
Location
Ger
You got it working ?? I got...

your script has to start with cd ~


Greets Sascha

So, this is how far I got until now:

- I wrote this BASh-script (lines after # not active yet) called achterom.sh (achterom = backyard in Dutch ;-)



- which I put in a .bat-file called achterom.bat like this:


Have a look at How to Create and Run Bash Shell Scripts on Windows 10 for more information on how to run bash-scripts on a Windows platform.


- the achterom.bat-file is then executed from 'Alerts'--> 'Run a program or execute a script' like this:




When I push "Test", it works like a charm, I get a Telegram-notification plus image which I pull directly from one of my Hikvision camera's (the 'wget -O $SnapFile1 ....'-line from the bash-script ).

This is what I see in Telegram after pushing the 'configure run alert' -'TEST'-button in Blue Iris (expected behaviour):



After pushing the 'configure run alert' --> 'OK' button however, I do NOT get a Telegram-notification at all when motion is detected, (which is unexpected because it works when I pushed the TEST button).

Blue Iris service is running as Admin by the way (because of Cam trigger sends text message, but does not run a script)




Until, now, I have not been able to figure out why everything does work as expected (telegram notification plus image) when hitting the TEST button, but not when motion is detected (no telegram notification at all). Any help would be really appreciated!!
 

tlow

n3wb
Joined
Nov 22, 2019
Messages
6
Reaction score
3
Location
Germany
Hey,

I created a telegram-bot in Nodejs that can send you a snapshot or a gif on alerts.

I currently just run the nodejs script on the same machine that runs blue iris.


If you have questions just ask me here, or create an issue on github so that others can benefit from it.
 

Mr White

n3wb
Joined
Mar 7, 2017
Messages
21
Reaction score
4
Hey,

I created a telegram-bot in Nodejs that can send you a snapshot or a gif on alerts.

I currently just run the nodejs script on the same machine that runs blue iris.


If you have questions just ask me here, or create an issue on github so that others can benefit from it.
Does the telegram alert come through just as quickly as the native motion alert?
 

tlow

n3wb
Joined
Nov 22, 2019
Messages
6
Reaction score
3
Location
Germany
Does the telegram alert come through just as quickly as the native motion alert?
Yes, there is no noticeable delay. I have not measured it but I would estimate it's at most 1 or 2 seconds. The objects triggering the alert are always fully visible in the gif, if that's what you are concerned about.
 

Mr White

n3wb
Joined
Mar 7, 2017
Messages
21
Reaction score
4
Than
Yes, there is no noticeable delay. I have not measured it but I would estimate it's at most 1 or 2 seconds. The objects triggering the alert are always fully visible in the gif, if that's what you are concerned about.
Thank you. I was just curious about speed of it. Well done on getting this working! Hopefully I can setup a group chat and have this working for my family who arnt technically minded.
 

tlow

n3wb
Joined
Nov 22, 2019
Messages
6
Reaction score
3
Location
Germany
Than


Thank you. I was just curious about speed of it. Well done on getting this working! Hopefully I can setup a group chat and have this working for my family who arnt technically minded.
I haven't used the bot in groups yet, it is used by 3 different telegram users independently. For security reasons you have to allow users to receive messages from the bot, but it's really easy to set up. Just send the bot the /start command and the userid is shown on the pc that runs the bot. Just add the id to the list of the allowed users and thats it.
 

joshwah

Getting the hang of it
Joined
Apr 25, 2019
Messages
150
Reaction score
83
Location
australia
okay got everything up and running... it responds when I do /start and /gif etc... however, whenever i 'test' the alert I get this error in the console:

 
Last edited:

tlow

n3wb
Joined
Nov 22, 2019
Messages
6
Reaction score
3
Location
Germany
okay got everything up and running... it responds when I do /start and /gif etc... however, whenever i 'test' the alert I get this error in the console:

Glad you tried it out.
It seems like there was an error returned by BI which is not handled. Hard for me to debug it with that message only, are you sure that your credentials are set correctly in the conf.json?
If you want to, we can debug this problem via DM. If we find the source of the problem, I can update that in the code.
 

pumo

n3wb
Joined
Nov 17, 2015
Messages
8
Reaction score
3
Hi
I am new with nodejs. what are depencies ?
"Use npm install inside project folder to install all the dependencies"
something is missing:
"
C:\blue-iris-telegram-bot>npm install index.js
+ index.js@0.0.3
added 70 packages from 89 contributors and audited 175 packages in 6.012s
found 0 vulnerabilities


C:\blue-iris-telegram-bot>npm run index.js
npm ERR! missing script: index.js

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\root\AppData\Roaming\npm-cache\_logs\2020-02-24T10_56_30_019Z-debug.log"

I installed nodejs with msi installer.
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
10,059
Reaction score
7,648
Location
USA
Computer programs are usually built from a whole lot of separate reusable pieces. A "dependency" is a piece that another piece depends on. The npm install command is nodejs's way of downloading all the pieces needed by your program so they are all available for your program to use.

Anyway I don't know where you got your usage instructions, but they do not match the project's readme file. The commands you should be running are npm install and npm start.
 

djsam

n3wb
Joined
Sep 7, 2015
Messages
4
Reaction score
1
Hi
Thank u for ur efforts! it looks promising

I'm receiving the following error any idea why?


(node:8036) UnhandledPromiseRejectionWarning: Error: Request failed with status code 404
at createError (C:\bluebot\node_modules\axios\lib\core\createError.js:16:15)
at settle (C:\bluebot\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (C:\bluebot\node_modules\axios\lib\adapters\http.js:237:11)
at IncomingMessage.emit (events.js:323:22)
at endReadableNT (_stream_readable.js:1204:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:8036) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command Line Options | Node.js v13.9.0 Documentation). (rejection id: 2)
(node:8036) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:8036) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of Error
at open (internal/fs/promises.js:209:10)
at Object.readFile (internal/fs/promises.js:501:20)
at C:\bluebot\index.js:230:16
(node:8036) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command Line Options | Node.js v13.9.0 Documentation). (rejection id: 5)
 

pumo

n3wb
Joined
Nov 17, 2015
Messages
8
Reaction score
3
Computer programs are usually built from a whole lot of separate reusable pieces. A "dependency" is a piece that another piece depends on. The npm install command is nodejs's way of downloading all the pieces needed by your program so they are all available for your program to use.

Anyway I don't know where you got your usage instructions, but they do not match the project's readme file. The commands you should be running are npm install and npm start.
Well, I just googled because I dont have any experience with nodejs. those commands wasnt clear enough to run :)
but it starts now with some errors.
I added my token, blueiris url,blueiris username, and blueiris password. gives errors that its running allready..
I have allready one bot chat, can it be used with that?

Code:
> node index.js "index.js"

Blue Iris Alert bot listening on port 3000!
1. enter your settings in conf.json and restart
2. contact the bot with /start
3. check this console output for the userId
4. add the userId to the ALLOWED_USER in conf.json
5. restart this bot
5. Use {ip}:3000/snapshot?camera=$CAM in blue iris alert web request to get a snapshot
Failed to process updates. TelegramError: 409: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
    at C:\blue-iris-telegram-bot\node_modules\telegraf\core\network\client.js:281:17
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: 409,
  response: {
    ok: false,
    error_code: 409,
    description: 'Conflict: terminated by other getUpdates request; make sure that only one bot instance is running'
  },
  description: 'Conflict: terminated by other getUpdates request; make sure that only one bot instance is running',
  parameters: {},
  on: { method: 'getUpdates?offset=0&limit=100&timeout=30', payload: {} }
 

pumo

n3wb
Joined
Nov 17, 2015
Messages
8
Reaction score
3
I manage to get it start now. I made new bot and started with instructions. Anyway maybe its better to have own bot for blueiris. To another bot I get messages from home assistant.
but it wont send any alerts or nothing. Idid enable those /snapshot and /gif , now I got same errors than @djsam
 
Last edited:

pumo

n3wb
Joined
Nov 17, 2015
Messages
8
Reaction score
3
address was long one I corrected to now when alert goes, or when I send test alert it crashes:

Code:
5. Use {ip}:3000/snapshot?camera=$CAM in blue iris alert web request to get a snapshot
(node:2280) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\blue-iris-telegram-bot\images\snapshot.jpg'
(node:2280) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
(node:2280) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
events.js:288
      throw er; / Unhandled 'error' event
      ^

Error: Cannot find ffmpeg
    at C:\blue-iris-telegram-bot\node_modules\fluent-ffmpeg\lib\processor.js:136:22
    at C:\blue-iris-telegram-bot\node_modules\fluent-ffmpeg\lib\capabilities.js:123:9
    at wrapper (C:\blue-iris-telegram-bot\node_modules\async\dist\async.js:272:20)
    at next (C:\blue-iris-telegram-bot\node_modules\async\dist\async.js:4584:24)
    at C:\blue-iris-telegram-bot\node_modules\async\dist\async.js:325:20
    at C:\blue-iris-telegram-bot\node_modules\fluent-ffmpeg\lib\capabilities.js:116:11
    at C:\blue-iris-telegram-bot\node_modules\fluent-ffmpeg\lib\utils.js:223:16
    at F (C:\blue-iris-telegram-bot\node_modules\which\which.js:68:16)
    at E (C:\blue-iris-telegram-bot\node_modules\which\which.js:80:29)
    at C:\blue-iris-telegram-bot\node_modules\which\which.js:89:16
Emitted 'error' event on FfmpegCommand instance at:
    at emitEnd (C:\blue-iris-telegram-bot\node_modules\fluent-ffmpeg\lib\processor.js:424:16)
    at C:\blue-iris-telegram-bot\node_modules\fluent-ffmpeg\lib\processor.js:433:16
    at wrapper (C:\blue-iris-telegram-bot\node_modules\async\dist\async.js:272:20)
    at next (C:\blue-iris-telegram-bot\node_modules\async\dist\async.js:4584:24)
    at C:\blue-iris-telegram-bot\node_modules\async\dist\async.js:325:20
    at wrapper (C:\blue-iris-telegram-bot\node_modules\async\dist\async.js:272:20)
    at next (C:\blue-iris-telegram-bot\node_modules\async\dist\async.js:4584:24)
    at C:\blue-iris-telegram-bot\node_modules\async\dist\async.js:325:20
    at C:\blue-iris-telegram-bot\node_modules\fluent-ffmpeg\lib\capabilities.js:519:16
    at C:\blue-iris-telegram-bot\node_modules\fluent-ffmpeg\lib\processor.js:136:16
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! blue-iris-telegram-bot@1.0.0 start: `node index.js "index.js"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the blue-iris-telegram-bot@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\root\AppData\Roaming\npm-cache\_logs\2020-02-25T12_00_12_052Z-debug.log
 

Attachments

Top