Skip to content

Commit

Permalink
Update Telegram docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bewuethr committed Oct 9, 2021
1 parent 6655cca commit b974e79
Showing 1 changed file with 13 additions and 33 deletions.
46 changes: 13 additions & 33 deletions docs/telegram.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,45 +73,25 @@ This is documented in the [BotFather documentation][1].

[2]: <https://core.telegram.org/bots/api#getupdates>

## Use a GitHub action to send Telegram messages
## Sending Telegram messages as part of the action

Armed with the token and the channel ID, we can send messages to our new
channel. An easy way for doing so is [appleboy/telegram-action][3].
channel. The Slack analyzer action uses [appleboy/telegram-action][3] for this
(transparently).

Assuming the Slack analyzer action is run in a step with ID `update`, the step
to send the diff would look like this:
All that has to be done is setting the optional `telegram-to` and
`telegram-token` inputs; assuming they are stored as secrets `TELEGRAM_TO` and
`TELEGRAM_TOKEN`:

```yaml
- name: Send Telegram message for change
# Do not send anything if the diff is empty
if: steps.update.outputs.diff-msg != ''
uses: appleboy/[email protected]
- name: Update Slack workspace analysis
uses: bewuethr/slack-analyzer@v0
with:
# The channel ID
to: ${{ secrets.TELEGRAM_TO }}
# The authorization token
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
# fromJSON is required to unescape the diff message
message: ${{ fromJSON(steps.update.outputs.diff-msg) }}
```

And the step to send the graph:

```yaml
- name: Send Telegram message for graph
# Don't send anything if the path has not been set
if: steps.update.outputs.graph-path != ''
uses: appleboy/[email protected]
with:
# The channel ID
to: ${{ secrets.TELEGRAM_TO }}
# The authorization token
token: ${{ secrets.TELEGRAM_TOKEN }}
# Set by the slack-analyzer step
photo: ${{ steps.update.outputs.graph-path }}
# Required to avoid an extra, empty message
message: ' '
name: Foo Corp
slack-bot-token: ${{ secrets.BOT_TOKEN }}
slack-user-token: ${{ secrets.USER_TOKEN }}
telegram-to: ${{ secrets.TELEGRAM_TO }}
telegram-token: ${{ secrets.TELEGRAM_TOKEN }}
```

And that's it! Happy telegramming!
Expand Down

0 comments on commit b974e79

Please sign in to comment.