Skip to content

Bot replies ​

A bot workflow replies by returning a result: kdeps sends the workflow's result back to the chat that delivered the message - Discord, Slack, Telegram, or stdout in stateless mode. There is no separate reply resource; end the workflow with an apiResponse: (or any resource whose output is text) and set it as targetActionId.

This is workflow mode with bot under settings.input.sources - see Input sources.

text
message -> workflow (llm -> reply) -> result text -> same chat

Basic usage ​

yaml
# workflow.yaml (abridged)
metadata:
  targetActionId: reply        # its result is the reply
settings:
  input:
    sources: [bot]
    bot:
      executionType: polling
      telegram: {}   # presence enables the platform; credentials are in ~/.kdeps/config.yaml bot_connections
yaml
# resources/llm.yaml
actionId: llm
name: Generate Reply
chat:
  model: llama3.2:1b
  prompt: "{{ input('message') }}"
yaml
# resources/reply.yaml
actionId: reply
name: Reply
requires: [llm]
apiResponse:
  success: true
  response: "{{ get('llm').message.content }}"   # the text sent to the chat

What is sent ​

Workflow resultReply text
apiResponse with a string responseThat string
apiResponse with a map or list responseThe response as JSON
A chat result (target is the chat resource itself)message.content
A plain stringThe string
Anything elseThe result as JSON

An empty result sends nothing. A failed workflow sends nothing and is logged; send a fallback with the resource's onError: if users should get one.

Stateless mode ​

executionType: stateless reads one message as JSON on stdin and prints the reply on stdout:

bash
echo '{"message":"What is 2+2?","platform":"cli"}' | kdeps run workflow.yaml
# 4

Full example ​

See the Stateless bot and Telegram bot examples.

See also ​

Released under the Apache 2.0 License.