@Notifica_bot

Integration guide

Once connected to the bot (notifica_bot), you receive an unique token to use and recall from various development languages, scripts or systems. This let you receive push messages from the bot.
For a detailed list of all available commands type /help in Telegram (inside the bot).
Any program or scripting language that you use must make an http request (GET) to:

http://notify.moosa.it:88/[your token]/[your message url encoded]

You have to replace [your token] with the token you received from the notifica_bot and [your message url encoded] with the message that you want to send. The message must be urlencoded properly (if it contains spaces or special characters). Here we provide some examples of calls in various languages.

[your token]@notify.moosa.it

Programs and systems can also send an email to [your tocken] @ notify.moosa.it, the system will convert the e-mail text into a push message.

With an email

Send an email to:

          
[your token]@notify.moosa.it
          
        

PHP

          
$token = '[your token]';
$message = rawurlencode("[your message]");
$result = file_get_contents("http://notify.moosa.it:88/$token/$message");
if ($result=="message sent") {
  
}
          
        

Python

After you installed requests ( pip install requests ):


import requests
token = '[your token]'
message = '[your message]'
response = requests.get("http://notify.moosa.it:88/"+token+"/"+message)
if response.text=="message sent":
  print "messaggio inviato"
          
        

Bash

          
rawurldecode() {
  printf -v REPLY '%b' "${1//%/\\x}"
  echo "${REPLY}"
}
TOKEN="[your token]"
MESSAGE=$(php -r "echo rawurlencode('[your message]');")
curl http://notify.moosa.it:88/$TOKEN/$MESSAGE
          
        

VB.Net

          
Dim token As String = "[your token]"
Dim message As String = "[your message]"
My.Computer.Network.DownloadFile("http://notify.moosa.it:88/" & token & "/" & message, "result.txt")
          
        

c#

          
using (WebClient wc = new WebClient())
{
   string token = "[your token]";
   string message = "[your message]";
   wc.DownloadFile("http://notify.moosa.it:88/" + token + "/" + message, "result.txt");
}
          
        

node js

          
var request = require('request');
var token = '[your token]'
var message = '[your message]'

request.get('http://notify.moosa.it:88/'+token+"/"+message, function (error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log("messaggio inviato");
    }
});
          
        

Asterisk solution 1

If you have CURL function installed in your asterisk, you have to use it replacing [your token] with the token you received from notifica bot, and the extension s with the correct one of your incoming contest.

          
exten => s,n,noop(${CURL(http://notify.moosa.it:88/[your token]/call%20from%20${CALLERID(num)})})
          
        

Asterisk solution 2

If you have not CURL installed, you can create a new file (AGI) inside /var/lib/asterisk/agi-bin directory with name "notifica.php" and permissions 755 (chmod 755 notifica.php), with the following contents:

          
#!/usr/bin/php
<?php
$token = '[your token]';
$message = rawurlencode("call from ".$argv[1]);
$result = file_get_contents("http://notify.moosa.it:88/$token/$message");
             
        

and execute it from your diaplan in this way:

          
exten => s,n,AGI(notifica.php,${CALLERID(num)})
          
        

Snom phone

Go to action url settings and put into incoming call the following url (replacing [your token] with the token you received from notifica bot)

          
http://notify.moosa.it:88/[your token]/call%20from%20$remote
          
        

if you want you may associate the alert to other keys or other events.

Arduino (Genuino)(Download the full example here)

Use ethernet library to create a simple http request, replace [your token] with the token you received from notifica bot.

          
#include <Ethernet.h>

char server[] = "notify.moosa.it";
.....

if (client.connect(server, 88)) {
  client.println("GET /[your token]/message%20url%20encoded HTTP/1.1");
  client.println("Host: www.arduino.cc");
  client.println("User-Agent: arduino-ethernet");
  client.println("Connection: close");
  client.println();
}
          
        
Arduino (Genuino)
Asterisk/Snom