kdeps-listeners-discord_gateway
v1.0.0Discord messages over the Gateway: runs the workflow once for each new message in a guild channel or a DM. The event is the message: input('content'), input('channel_id'), input('author').username. Messages from bots are left out. Reply with the discord_post component. Enable the Message Content intent for the bot. Requires DISCORD_BOT_TOKEN or the vault secret discord_bot_token.
set listeners / shelf workflow
LLM context: none - kdeps uses it without sending it to the model
Where it runs
Part of the listeners set, used in workflow and agent mode. Ready-made event sources for deploy.input.listen: a Telegram poll, Slack Socket Mode and the Discord Gateway, each one transport block in YAML.
- a workflow names a listener under deploy.input.listen
- the listener is read from the listeners set when kdeps run startslisteners/discord_gateway
- its transport (poll, websocket, ...) starts
- each event runs the workflow once
Loaded by: kdeps (agent loop), kdeps run, kdeps exec
In the code: kdeps (agent loop)listen.WakeAddrslisten.readListenerAsset
Install
A kdeps asset: installed with the first-run profile that includes its set, or the first time a command needs it, and updated without a new release.
Pin a version with kdeps install listeners/discord_gateway@<version>.
Contents
Discord messages over the Gateway: runs the workflow once for each new message in a guild channel or a DM. The event is the message: input('content'), input('channel_id'), input('author').username. Messages from bots are left out. Reply with the discord_post component. Enable the Message Content intent for the bot. Requires DISCORD_BOT_TOKEN or the vault secret discord_bot_token.
- kdeps
- >=3.6.0
websocket:
env:
TOKEN:
- DISCORD_BOT_TOKEN
- secret:discord_bot_token
url: wss://gateway.discord.gg/?v=10&encoding=json
heartbeat:
send: '{"op":1,"d":{{or .state.seq "null"}}}'
on:
- when: "{{if eq (int .msg.op) 10}}y{{end}}"
every: "{{.msg.d.heartbeat_interval}}ms"
send: '{"op":2,"d":{"token":"{{.env.TOKEN}}","intents":37377,"properties":{"os":"linux","browser":"kdeps","device":"kdeps"}}}'
- when: "{{.msg.s}}"
set:
seq: "{{.msg.s}}"
- when: '{{if and (eq .msg.t "MESSAGE_CREATE") (not .msg.d.author.bot)}}y{{end}}'
emit: "{{json .msg.d}}"
- when: "{{if or (eq (int .msg.op) 7) (eq (int .msg.op) 9)}}y{{end}}"
reconnect: true
version: 1.0.0
kdeps: ">=3.6.0"
description: 'Discord messages over the Gateway: runs the workflow once for each new message in a guild channel or a DM. The event is the message: input(''content''), input(''channel_id''), input(''author'').username. Messages from bots are left out. Reply with the discord_post component. Enable the Message Content intent for the bot. Requires DISCORD_BOT_TOKEN or the vault secret discord_bot_token.'
websocket:
env:
TOKEN: [DISCORD_BOT_TOKEN, "secret:discord_bot_token"]
url: 'wss://gateway.discord.gg/?v=10&encoding=json'
heartbeat:
# op 1 carries the last sequence number, or null before the first event.
send: '{"op":1,"d":{{or .state.seq "null"}}}'
on:
# op 10 Hello: start the heartbeat at the interval Discord sets, then
# identify. Intents: GUILDS, GUILD_MESSAGES, DIRECT_MESSAGES, MESSAGE_CONTENT.
- when: '{{if eq (int .msg.op) 10}}y{{end}}'
every: '{{.msg.d.heartbeat_interval}}ms'
send: '{"op":2,"d":{"token":"{{.env.TOKEN}}","intents":37377,"properties":{"os":"linux","browser":"kdeps","device":"kdeps"}}}'
- when: '{{.msg.s}}'
set:
seq: '{{.msg.s}}'
- when: '{{if and (eq .msg.t "MESSAGE_CREATE") (not .msg.d.author.bot)}}y{{end}}'
emit: '{{json .msg.d}}'
# op 7 Reconnect and op 9 Invalid Session: connect and identify again.
- when: '{{if or (eq (int .msg.op) 7) (eq (int .msg.op) 9)}}y{{end}}'
reconnect: true
Versions
| Version | Published | Status | Source |
|---|---|---|---|
| 1.0.0 | 11/26/2026 | active | GitHub v1.0.0 |
Details
- Author
- kdeps
- License
- Apache-2.0
- Latest Version
- 1.0.0
- Published
- 11/26/2026