Jump to content

Bokonon

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Bokonon

  1. Adding the following to NotificationAgents.xml allows Telegram to work for notifications.  Not the easiest process to setup though.  First you have to send @BotFather a message '/newbot', after a few steps it sends you back your HTTP API.  Then you need to start a conversation with your bot in order to get the Chat ID to send to.  Not sure there is an easy way to integrate this into the settings page, I manually queried the API to get the chat ID.

      <Agent>
        <Name>Telegram</Name>
        <Variables>
          <Variable Help="The API key can be found [a href='https://core.telegram.org/bots/api' target='_blank'] [u]here[/u].[/a]" Desc="API key" Default="">API_KEY</Variable>
          <Variable Help="Chat ID [a href='https://core.telegram.org/bots/api' target='_blank'] [u]here[/u].[/a]" Desc="Chat ID" Default="">CHAT_ID</Variable>
          <Variable Help="Specify the fields which are included in the message body of the notification." Desc="Notification Message" Default="$DESCRIPTION">MESSAGE</Variable>
        </Variables>
        <Script>
          <![CDATA[
          #!/bin/bash
          ##########
          {0}  
          ##########
          MESSAGE=$(echo -e "$MESSAGE")
          URL=https://api.telegram.org/bot$(echo -e "$API_KEY")
          CHATID=$(echo -e "$CHAT_ID")
    
          curl -s -k -G \
          --data-urlencode "text=$MESSAGE" \
          $URL/sendMessage?chat_id=$CHATID
          ]]>
        </Script>
      </Agent>

    Edit: While looking for something else I noticed theres another way to get the chatid.  Send '/getid' to IDBot @myidbot (https://telegram.me/myidbot) and it will reply with your chat id

     

    • Upvote 4
×
×
  • Create New...