当前位置: 首页 > Skill >

Tally Extractor

Tally Extractor

Tally Extractor

用于 TallyPrime的实例 A 技能(提取器),通过 Telegram/WhatsApp 解析 PDF/图片中的发票/账单,提取结构化数据(交易方、GSTIN、商品、税额等...

1.0.0 2026.11.04 798
获取Skill文件查看使用说明
作 者:沈景 许可证: 更新时间:2026.11.04
本文目录展开

Tally Extractor Skill

Extract invoice/bill data from PDFs and images received via Telegram or WhatsApp, convert to a canonical JSON payload, and POST to the bridge service on Instance B for Tally entry.

  • No direct Tally access: This skill does NOT connect to TallyPrime. Voucher posting is handled by tally-skill on Instance B.
  • Telegram/WhatsApp interface: User sends PDF/image → this skill extracts → bridge → Tally.
  • Structured output: Always emit the canonical JSON schema (see reference/extraction-schema.md).

Hero Use Case: Telegram invoice → Tally entry

Goal: zero manual entry for CAs handling many clients.

  1. User sends invoice PDF/image via Telegram.
  2. This skill extracts: company, party, GSTIN, date, invoice no, items (description, HSN, qty, rate, tax), total.
  3. Validate extraction: tax math check, GSTIN format, required fields present.
  4. POST canonical JSON to bridge (/v1/post-voucher).
  5. Receive result from bridge and reply to user in accountant-friendly language.

When to use this skill

Scope note: This skill is for Instance A (Extractor). It does not post to Tally — that responsibility belongs to tally-skill on Instance B.

Use when:

  • User sends a PDF or image of an invoice/bill via Telegram/WhatsApp
  • User requests to extract data from a document
  • User asks to "add this invoice to Tally" (extract + forward to bridge)
  • User provides invoice details as text message (parse and forward)

Do NOT use this skill for:

  • Direct Tally operations (reports, ledger queries) — those go to Instance B
  • PDF generation (tallyca runs on Instance B)
  • Master management (ledgers, groups) — that's on Instance B

Critical rules (must follow)

  1. Never hallucinate data: If a field is unclear or missing from the document, mark it as low-confidence or ask the user. Do not invent GSTINs, HSN codes, or amounts.
  2. Validate GSTIN format: 15 characters, pattern ^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$. If invalid, flag it.
  3. Validate HSN format: 4-8 digits. If invalid, flag it.
  4. Tax math check: taxable_amount × tax_rate / 100 ≈ tax_amount (within ±0.01). If mismatch, flag it.
  5. Total check: Sum of item amounts + taxes = total (within ±1 for rounding). If mismatch, flag it.
  6. Place of Supply: Derive from first 2 digits of party GSTIN (state code). Map to state name using reference/extraction-schema.md state code table.
  7. Inter-state vs Intra-state: If company GSTIN state ≠ party GSTIN state → IGST. If same state → CGST + SGST.
  8. Dates: Extract as YYYY-MM-DD. Common formats on invoices: DD/MM/YYYY, DD-MM-YYYY, DD.MM.YYYY, MMM DD, YYYY.
  9. Idempotency key: Generate deterministic GUID using pattern {companyShort}-{voucherType}-{invoiceNumber}-{date}.
  10. Confidence scores: Assign confidence (0.0-1.0) to each extracted field. Flag fields with confidence < 0.7 for user confirmation.

Extraction workflow

Step 1: Receive document

User sends PDF or image via Telegram. The document is available for OCR/vision processing.

Step 2: Check bridge health

Before extraction, verify Instance B is reachable:

curl -s -X GET 
  -H "Authorization: Bearer $BRIDGE_BEARER" 
  "$BRIDGE_URL/v1/health"

Expected response:

{
  "tally": "ok",
  "company_default": "ABC Company",
  "version": "1.0.0"
}

If tally: "down", inform user: "Tally is not running on the client machine. Please ask them to open TallyPrime."

Step 3: Extract data

Parse the document and extract:

Field Source Validation
Party name Invoice header Required
Party GSTIN Near party name or GST section 15-char format
Company GSTIN Near company name or letterhead 15-char format
Invoice number Invoice header Required
Invoice date Invoice header Parse to YYYY-MM-DD
Items Line items table At least one
Item description Line item Required per item
HSN/SAC Line item 4-8 digits
Quantity Line item Numeric
Unit Line item Optional
Rate Line item Numeric
Tax rate Line item or GST section Percentage
CGST/SGST/IGST amounts GST section Numeric
Total Invoice footer Required, must balance
Narration Notes section Optional

Step 4: Determine voucher type

Document type Voucher type
Purchase invoice (we are buyer) Purchase
Sales invoice (we are seller) Sales
Payment receipt Receipt
Payment voucher Payment
Credit note CreditNote
Debit note DebitNote

Clues:

  • "Tax Invoice" with company as seller → Sales
  • "Tax Invoice" with company as buyer → Purchase
  • "Receipt" or "Payment Received" → Receipt
  • "Credit Note" in header → CreditNote

If ambiguous, ask user: "Is this a purchase (you bought) or sales (you sold)?"

Step 5: Validate extraction

Run these checks before sending to bridge:

Check Rule Action if fails
Required fields All required fields present List missing fields, ask user
GSTIN format 15-char regex match Flag invalid, ask user
HSN format 4-8 digits Flag invalid, ask user
Tax math taxable × rate / 100 ≈ tax Flag mismatch, ask user
Total balance items + taxes = total (±1) Flag mismatch, ask user
Date parseable Valid date Ask user for correct date

Step 6: Build canonical JSON

Construct the JSON payload per reference/extraction-schema.md:

{
  "schema_version": "1.0",
  "request_id": "uuid-v4",
  "idempotency_key": "abc-purchase-xyz-186-20260518",
  "company": "ABC Company",
  "voucher": {
    "type": "Purchase",
    "date": "2026-05-18",
    "number": "186",
    "is_invoice_mode": true,
    "voucher_class": null,
    "narration": "Against Invoice 186",
    "party": {
      "name": "XYZ Party",
      "gstin": "27AABCU9603R1ZM",
      "place_of_supply": "Maharashtra",
      "registration_type": "Regular"
    },
    "company_gstin": "27AABCU9603R1ZN",
    "items": [...],
    "taxes": {...},
    "total": 46199.83,
    "bill_allocations": [...]
  },
  "source": {
    "kind": "pdf",
    "filename": "invoice_186.pdf",
    "extracted_at": "2026-05-18T10:30:00Z"
  },
  "confidence": {
    "overall": 0.93,
    "fields": {...}
  }
}

Step 7: POST to bridge

Send the JSON to Instance B:

# Compute HMAC
BODY='{"schema_version":"1.0",...}'
SIGNATURE=$(echo -n "$BODY" | openssl dgst -sha256 -hmac "$BRIDGE_HMAC_SECRET" | cut -d' ' -f2)

curl -X POST 
  -H "Content-Type: application/json" 
  -H "Authorization: Bearer $BRIDGE_BEARER" 
  -H "X-Signature: hmac-sha256=$SIGNATURE" 
  -H "Idempotency-Key: abc-purchase-xyz-186-20260518" 
  -d "$BODY" 
  "$BRIDGE_URL/v1/post-voucher"

Full HTTP contract in reference/bridge.md.

Step 8: Handle response

Success

{
  "status": "posted",
  "guid": "abc-purchase-xyz-186-20260518",
  "voucher_number": "186",
  "company": "ABC Company",
  "summary": "Purchase voucher posted: XYZ Party, ₹46,199.83",
  "masters_created": ["XYZ Party"]
}

Reply to user (see reference/prompts.md):

Entry posted to Tally.

Company: ABC Company
Type: Purchase
Party: XYZ Party
Invoice No: 186
Date: 18 May 2026
Amount: ₹46,199.83 (Taxable: ₹39,152.40 + IGST: ₹7,047.43)

New ledger created: XYZ Party

Needs Clarification

{
  "status": "needs_clarification",
  "missing_fields": ["voucher.voucher_class"],
  "message": "Please confirm the voucher class name (e.g., 'Purchase @ 18 %')."
}

Forward the question to the user.

Error

{
  "status": "error",
  "error_code": "TALLY_UNREACHABLE",
  "message": "Could not connect to Tally."
}

Reply to user: "Tally is not responding. Please check that TallyPrime is open and try again."

Company name handling

The company name must match exactly in TallyPrime. Strategies:

  1. Explicit in document: Extract from invoice letterhead
  2. User specified: User may say "Add to ABC Company"
  3. Default from bridge: /v1/health returns company_default
  4. Ask user: If unclear, ask "Which Tally company should this entry go to?"

Voucher class handling

Some Tally companies use voucher classes for automatic GST splitting. This skill does NOT know which class to use — that's Instance B's job.

  • If user specifies class in message (e.g., "use Sales @ 18 %"), include in JSON
  • If not specified, leave voucher_class: null and let Instance B handle it
  • If Instance B returns needs_clarification for class, forward to user

Confidence scoring

Assign confidence scores based on:

Extraction quality Confidence
Clear text, high contrast, exact match 0.95 - 1.0
Readable but some ambiguity 0.7 - 0.94
Blurry, low contrast, guessed 0.4 - 0.69
Highly uncertain 0.0 - 0.39

Fields with confidence < 0.7 should be flagged for user confirmation before posting.

State code to state name mapping

First 2 digits of GSTIN → Place of Supply:

Code State
01 Jammu and Kashmir
02 Himachal Pradesh
03 Punjab
04 Chandigarh
05 Uttarakhand
06 Haryana
07 Delhi
08 Rajasthan
09 Uttar Pradesh
10 Bihar
11 Sikkim
12 Arunachal Pradesh
13 Nagaland
14 Manipur
15 Mizoram
16 Tripura
17 Meghalaya
18 Assam
19 West Bengal
20 Jharkhand
21 Odisha
22 Chhattisgarh
23 Madhya Pradesh
24 Gujarat
25 Daman and Diu
26 Dadra and Nagar Haveli
27 Maharashtra
28 Andhra Pradesh (Old)
29 Karnataka
30 Goa
31 Lakshadweep
32 Kerala
33 Tamil Nadu
34 Puducherry
35 Andaman and Nicobar Islands
36 Telangana
37 Andhra Pradesh
38 Ladakh

Deployment topology

There is exactly one chat interface (Telegram on Instance A). Instance B has no Telegram/WhatsApp — only the bridge HTTP endpoint.

flowchart LR
  User["CA / client on Telegram"] -->|"PDF / image"| TgBot["Telegram bot (Instance A)"]
  subgraph A["Instance A on dev EC2"]
    TgBot --> OpenClawA["OpenClawnLLM: Codex Plus session"]
    OpenClawA --> ExtractorSkill["tally-extractor-skill"]
  end
  OpenClawA -->|"HTTPS POST /v1/post-voucher"| Bridge["bridge-servicen(client box)"]
  subgraph B["Instance B on client CPU"]
    Bridge --> OpenClawB["OpenClawnLLM: OpenAI API key"]
    OpenClawB --> TallySkill["tally-skill"]
    TallySkill --> Tally["TallyPrimenlocalhost:9000"]
  end
  Bridge --> OpenClawA
  OpenClawA --> User
Environment Instance A Instance B Tally access
Production Your EC2 (Telegram, Codex Plus) Client mini-PC beside Tally B → http://localhost:9000 (no ngrok for Tally)
Dev / testing Same Ubuntu EC2 Second OpenClaw on same EC2 B uses ngrok URL to remote Tally

Instance A reaches B via an inbound tunnel on the client box (ngrok http 8787 or Cloudflare Tunnel). Share BRIDGE_URL, BRIDGE_BEARER, and BRIDGE_HMAC_SECRET with the team running A.

Instance A configuration checklist

Step Setting Value
1 Host Ubuntu EC2 (or dev server)
2 Install Node.js, OpenClaw
3 LLM OpenAI ChatGPT Codex Plus session (subscription)
4 Skill loaded tally-extractor-skill/ only — do not load tally-skill/
5 Channel Telegram bot token on A only
6 BRIDGE_URL https://<client-tunnel>.ngrok.app (no trailing slash)
7 BRIDGE_BEARER Shared secret from client team
8 BRIDGE_HMAC_SECRET Shared HMAC secret from client team
9 Do not set TALLY_URL on Instance A
10 Preflight curl -H "Authorization: Bearer $BRIDGE_BEARER" $BRIDGE_URL/v1/health → tally: ok

Reference files

  • Extraction schema: reference/extraction-schema.md — Full JSON schema, examples
  • Bridge HTTP contract: reference/bridge.md — Endpoints, auth, errors
  • Reply templates: reference/prompts.md — User-facing messages

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,016
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,004
PHP集成RabbitMQ实现消息队列的完整步骤

使用 php-amqplib 库,通过建立连接、声明交换机与队列并绑定,即可在 PHP 中实现消息的发送与消费。

2026.05.24 1,001
Apache开启.htaccess及使用方法详解

本文介绍如何在本地Apache环境中启用.htaccess文件,主要涉及修改httpd.conf中的AllowOverride参数。同时详细解析.htaccess的多种实用功能,包括自定义错误页面、目录密码保护、IP访问限制、URL自动转向、默认首页设置以及防止图片盗链等配置方法,并分析了使用.htaccess对服务器性能和安全性的潜在影响。

2026.05.09 1,001
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,001
Linux内核提权风险待核实,先查版本与补丁

CVE-2026-78901在摘要中被称为Linux内核ext4本地提权漏洞,CVSS评分7.8,但上游正文暂未核实。本文提供通用只读排查命令,帮运维和开发者核对当前运行内核、发行版补丁及升级生效状态。

2026.12.02 1,000
Skill 文件
  • SKILL.md
    • Tally Extractor Skill
    • Hero Use Case: Telegram invoice → Tally entry
    • When to use this skill
    • Critical rules (must follow)
    • Extraction workflow
      • Step 1: Receive document
      • Step 2: Check bridge health
      • Step 3: Extract data
      • Step 4: Determine voucher type
      • Step 5: Validate extraction
      • Step 6: Build canonical JSON
      • Step 7: POST to bridge
      • Step 8: Handle response
        • Success
        • Needs Clarification
        • Error
    • Company name handling
    • Voucher class handling
    • Confidence scoring
    • State code to state name mapping
    • Deployment topology
    • Instance A configuration checklist
    • Reference files
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期