Freshping and Pipedream with Telegram API

Hello guys!
I came here to show you how to integrate Freshping with pipedream with Telegram in python
It sends a telegram message whenever the monitoring server goes down, and displays the information

(Remembering: You need to create a webhook and link it to the Freshping integrations, so the pipedream webhook will receive the information)

from datetime import datetime
import telepot, pytz

def handler(pd: "pipedream"):

  bot = telepot.Bot('Your bot Token')
  chat = ('Your chat ID')

  sp = pytz.timezone("America/Sao_Paulo")

  currentDateAndTime = datetime.now(sp)
  currentTime = currentDateAndTime.strftime("%H:%M:%S")

  fresh_server = pd.steps["trigger"]["event"]["body"]["check_url"]
  fresh_status = pd.steps["trigger"]["event"]["body"]["response_summary"]
  fresh_text = pd.steps["trigger"]["event"]["body"]["text"]
  fresh_name = pd.steps["trigger"]["event"]["body"]["check_name"]

  response = ("Status: " + fresh_status + "\n" + "Name: " + fresh_name + "\n" + "URL: " + fresh_server + "\n" + "Time: " + currentTime + "\n \n" + "Server message: \n" + fresh_text)

  bot.sendMessage(chat, response)

  return ('Ok!')
1 Like

Hello @steam2marco,

Thank you so much for your effort! We really appreciate it!

1 Like