aibeginner10 min setupby Mantle

Q&A over a fetched document

Answer a question about any public document: fetch it over HTTP, hand the text plus the question to an LLM with a grounding prompt, and post the answer to a callback URL.

QuestionFetch documentAnswer from the Post answer to c

Drag to pan, pinch to zoom. This is the real graph the template installs.

Purpose

Answer a question about any public document: fetch it over HTTP, hand the text plus the question to an LLM with a grounding prompt, and post the answer to a callback URL.

How it works

What it does

  • Webhook in: {question, document_url, callback_url}.
  • Fetch document GETs the URL; Answer from the document runs ai.llm with a grounding system prompt so the model only answers from the fetched text.
  • Post answer to callback delivers {question, answer, document_url} to your callback.

Nodes 4

  1. 01Questiontrigger.webhookTrigger
  2. 02Fetch documenthttp.requestHTTP
  3. 03Answer from the documentai.llmAI
  4. 04Post answer to callbackhttp.requestHTTP
View template JSON
{
  "format": "mantle-workflow/v1",
  "id": "ai-doc-qa",
  "name": "Q&A over a fetched document",
  "graph": {
    "nodes": [
      {
        "id": "webhook",
        "type": "trigger.webhook",
        "label": "Question",
        "config": {
          "slug": "doc-qa",
          "input_schema": {
            "required": [
              "question",
              "document_url",
              "callback_url"
            ],
            "properties": {
              "question": {
                "type": "string"
              },
              "document_url": {
                "type": "string"
              },
              "callback_url": {
                "type": "string"
              }
            }
          }
        },
        "worker_type": "generic-worker",
        "position": {
          "x": 60,
          "y": 220
        }
      },
      {
        "id": "fetch_doc",
        "type": "http.request",
        "label": "Fetch document",
        "config": {
          "method": "GET",
          "url": "{{ steps.webhook.document_url }}",
          "timeout_seconds": 20
        },
        "worker_type": "generic-worker",
        "position": {
          "x": 380,
          "y": 220
        }
      },
      {
        "id": "answer",
        "type": "ai.llm",
        "label": "Answer from the document",
        "config": {
          "model": "claude-sonnet-4-5",
          "temperature": 0,
          "max_tokens": 600,
          "system_prompt": "Answer ONLY from the supplied document. If the answer is not in it, say so. Quote the relevant passage briefly.",
          "user_prompt": "DOCUMENT:\n{{ steps.fetch_doc.body }}\n\nQUESTION: {{ steps.webhook.question }}"
        },
        "worker_type": "ai-worker",
        "position": {
          "x": 700,
          "y": 220
        }
      },
      {
        "id": "post_answer",
        "type": "http.request",
        "label": "Post answer to callback",
        "config": {
          "method": "POST",
          "url": "{{ steps.webhook.callback_url }}",
          "headers": {
            "Content-Type": "application/json"
          },
          "json": {
            "question": "steps.webhook.question",
            "answer": "steps.answer.response",
            "document_url": "steps.webhook.document_url"
          }
        },
        "worker_type": "generic-worker",
        "position": {
          "x": 1020,
          "y": 220
        }
      }
    ],
    "edges": [
      {
        "from": "webhook",
        "to": "fetch_doc"
      },
      {
        "from": "fetch_doc",
        "to": "answer"
      },
      {
        "from": "answer",
        "to": "post_answer"
      }
    ]
  }
}

Requirements

The connections and permissions each step needs, from the node contracts in the catalog.

  • AnthropicAPI key

    Used by Answer from the document.

    Credential: {"api_key"}

    • The provider adapter is chosen from the connection; `model` must belong to it.

Setup

  • Choose an AI connection on Answer from the document.
  • Optional: put the document behind an HTTP connection (base URL + auth) and use path instead of url on Fetch document.

Sample input and output

Synthetic examples: node-contract samples or placeholders, never customer data.

Input

The fields the template declares or reads from the request body. Values are placeholders.

{
  "question": "<question>",
  "document_url": "<document_url>",
  "callback_url": "<callback_url>"
}

Output

Post answer to callback http.request

{
  "body": null,
  "headers": {},
  "status_code": 0
}

Failure handling

What the graph does when a step fails, read from its retry settings, error branches and error policies.

  • Fetch document: the request times out after 20 s.
  • A step that fails, after any retries, fails the run. The failed step is kept with its input and error.

See it run, then make it yours.

Templates install as drafts. Edit any step, and Workflow Health re-checks the graph on every save.