Pechkin
Pechkin is a small webhook → messenger proxy (currently Slack + Telegram). You define a config directory with bots, channels, message templates, and Pechkin turns incoming JSON POST requests into formatted messages.
Quickstart (use the bundled examples/)
1) Install
gem install pechkin2) Configure a bot token (Slack example)
The bundled config uses examples/bots/marvin.yml:
token_env: MARVIN_BOT_TOKEN
connector: slackSet the env var before you run Pechkin:
export MARVIN_BOT_TOKEN=xoxb-your-actual-token-here3) Validate configuration
pechkin -c examples --check --list4) Run the server
Default bind is 127.0.0.1:9292:
pechkin -c examples5) Send a request
curl -X POST -H 'Content-Type: application/json' \
--data '{"name":"all"}' \
http://127.0.0.1:9292/my-org-random/hello6) Preview rendering from CLI (no HTTP)
--send expects channel/message (no leading slash):
pechkin -c examples --send my-org-random/hello --data '{"name":"all"}' --previewConcepts
- Bot: how Pechkin authenticates to a messenger API (Slack/Telegram).
-
Channel: where to deliver messages (one channel config can target multiple
chat_ids). - Message: how to render data into text + connector-specific payloads.
-
View: ERB templates stored in
views/.
Configuration basics
Pechkin expects a directory layout:
.
├── bots/
│ └── marvin.yml
├── channels/
│ └── my-org-random/
│ ├── _channel.yml
│ └── hello.yml
└── views/
└── hello.erb
Bots (bots/*.yml)
Each bot file defines:
-
token_env: env var name that contains the bot token -
connector:slackortelegram(also acceptstg)
Example:
# bots/marvin.yml
token_env: MARVIN_BOT_TOKEN
connector: slackViews (views/**/*.erb)
Views are ERB templates rendered with trim_mode: '-'.
Example:
Hello, <%= name %>!Channels (channels/<channel_name>/_channel.yml)
Channel config defines:
-
bot: which bot to use -
chat_ids: a string or list of destination chat IDs / channel IDs
Example:
# channels/my-org-random/_channel.yml
chat_ids: '#random'
bot: marvinMessages (channels/<channel_name>/*.yml)
Message config defines:
-
template: view path relative toviews/(e.g.hello.erb) -
variables: static variables merged into request data (request keys override) - optional connector-specific fields like
slack_attachments,telegram_parse_mode
Example:
# channels/my-org-random/hello.yml
template: hello.erbTemplate expansion inside message config
For nested fields you can use { template: "..." } to render a template and replace that value. The object must contain only the template key.
Example:
template: gitlab-commit.erb
slack_attachments:
- text:
template: gitlab-commit-attachment.erbMessage values substitution (${...})
Any string value in message config can substitute ${var} from the request JSON / variables.
Example:
slack_attachments:
- title: Author
value: "${author}"Filters (Allow / Forbid)
You can control whether a message is sent using either allow or forbid rules (but not both).
-
allow: message is sent if any rule matches (OR) -
forbid: message is sent if no rule matches
Example allow:
allow:
- branch: 'master'Example forbid:
forbid:
- branch: 'testing'Connector-specific parameters
Telegram
-
telegram_parse_mode: passed to Telegramparse_mode(default:HTML)
Slack
-
slack_attachments: passed as Slackattachmentstochat.postMessage. See Slack message attachments docs.
Slack: email-based user resolution (v2.0.2+)
To send a direct message to a user by email:
- Put
'email'in the channel’schat_ids - Include an
emailfield in the POST request JSON
Example channel config:
bot: marvin
chat_ids:
- 'email'Example request:
{
"email": "user@example.com",
"name": "all"
}HTTP API
-
Endpoint:
POST /:channel/:message - Body: JSON object
-
Content-Type:
application/json
Example:
curl -X POST -H 'Content-Type: application/json' \
--data '{"name":"all"}' \
http://127.0.0.1:9292/my-org-random/helloAuthorization (Basic Auth via .htpasswd)
If <config-dir>/pechkin.htpasswd exists (or you pass --auth-file), Pechkin will enforce HTTP Basic auth.
Create/update credentials:
# create/update examples/pechkin.htpasswd
pechkin -c examples --add-auth root:root123Use a custom htpasswd file:
pechkin -c examples --add-auth root:root123 --auth-file /etc/config/pechkin.htpasswd
pechkin -c examples --auth-file /etc/config/pechkin.htpasswdDocker quickstart
The repo ships docker/docker-compose.yml that mounts ../examples into the container.
cd docker
MARVIN_BOT_TOKEN=xoxb-your-actual-token-here docker compose up --buildCLI
Run:
pechkin --helpCommon flows:
pechkin -c examples --check --list
pechkin -c examples --send my-org-random/hello --data '{"name":"all"}' --preview
pechkin -c examples --port 9292 --address 127.0.0.1Metrics
Pechkin exposes Prometheus metrics at:
curl http://127.0.0.1:9292/metricsIncludes:
pechkin_start_time_secondspechkin_version{version="..."}
Troubleshooting
-
Bot token missing: ensure the env var named in
token_envis exported before running Pechkin.\n+ Example:export MARVIN_BOT_TOKEN=...\n+- CLI preview/send endpoint format:--senduseschannel/message(no leading/).\n+- Template prints nothing: use<%= ... %>(output) not<% ... %>(no output).
Who the heck is Pechkin?
Pechkin is a postman from a Soviet animated film series.