#Sales Agent is freezing

1 messages Β· Page 1 of 1 (latest)

candid hedge
#

Sales&Admin Agent β€” A human-in-the-loop AI sales agent for WhatsApp**

I built an AI sales agent for my furniture business that handles the entire customer journey on WhatsApp β€” in Albanian.

Customers ask about products, the agent checks live inventory from PostgreSQL, answers with real prices, and collects order details. When someone's ready to buy, it queues the order, reserves the stock, and pings me on Telegram for approval. One tap to approve β€” then the customer gets a WhatsApp confirmation and the order writes to the database.

No chatbot scripts. No hard-coded responses. The agent reads Markdown prompt files and decides which CLI tool to run. Policy lives in text files. Logic lives in testable Python scripts.

Built with: OpenClaw (WhatsApp gateway), Python, PostgreSQL, Telegram Bot API, Streamlit dashboard, OpenAI for product text parsing.

-But it is not working correctly and according to my instructions
-sales agent is freezing and not following instructions. I want to know for this use case of mine how should I configure the agent's md files.

lofty pumiceBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> βœ… Mark Solution

wicked houndBOT
#

First thing: please paste openclaw --version β€” freezing/instruction-following issues can be version-specific.

For your use case, don’t put the whole sales flow only in AGENTS.md. Use this split:

  • AGENTS.md: hard business rules + safety boundaries
  • SOUL.md / IDENTITY.md: Albanian tone/personality only
  • TOOLS.md: exact local script names/commands and what each one does
  • skills/sales-agent/SKILL.md: the step-by-step sales workflow
  • MEMORY.md: durable business facts only, not secrets

OpenClaw injects workspace files like AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, and MEMORY.md into the prompt, while skills are listed and loaded when relevant. Keep these files short, because large files can be truncated or bloat context. (docs.openclaw.ai)
Docs: https://docs.openclaw.ai/concepts/system-prompt https://docs.openclaw.ai/concepts/context

Recommended skills/sales-agent/SKILL.md shape:

#
---
name: sales_agent
description: Handles Albanian WhatsApp furniture sales using inventory/order tools.
---

# Sales Agent Workflow

You are a furniture sales assistant speaking Albanian.

## Non-negotiable rules
- Never invent prices, stock, dimensions, delivery times, or discounts.
- Before giving product availability or price, call the inventory lookup tool/script.
- If inventory lookup fails, apologize briefly and ask the customer to wait for human confirmation.
- Never reserve stock until the customer clearly confirms they want to buy.
- After stock is reserved, notify admin on Telegram and wait for approval.
#
- Do not confirm the order to the customer until admin approval succeeds.
- If admin rejects, explain politely and offer alternatives.

## Conversation flow
1. Understand the customer’s request.
2. Extract product name, size, color, quantity, city, and phone number if available.
3. Call inventory lookup.
4. Present only verified options.
5. Ask for missing order details.
6. When customer confirms purchase, call reserve/order queue script.
7. Notify admin for approval.
8. After approval, send final WhatsApp confirmation.

## Failure behavior
- If a script hangs or returns unclear output, stop and ask for human help.
#
- Do not retry more than once.
- Do not loop.

For freezing specifically, check these:

  1. Run /context detail and see if your .md files are huge/truncated.
  2. Add timeouts inside your Python scripts.
  3. Make scripts return simple JSON, not long logs.
  4. Avoid one tool doing β€œeverything”; split into lookup, reserve, notify_admin, finalize_order.
  5. Test from CLI with openclaw agent --message "..." before testing through WhatsApp. Skills live under the workspace, usually ~/.openclaw/workspace/skills/..., and a new session or gateway restart makes OpenClaw pick them up. (docs.openclaw.ai)
    Docs: https://docs.openclaw.ai/tools/creating-skills

If you paste your current AGENTS.md, TOOLS.md, SKILL.md, and openclaw --version, I can help restructure them. Don’t paste API keys, DB passwords, or customer data.

rocky sage
#

Hey - please only use krill for OpenClaw support - and open claw related functionality

wicked houndBOT
#

Yep β€” I’ll keep Krill focused on OpenClaw support/functionality here. 🦐

candid hedge
#

In what format should I upload this MD file since I'm not allowed to?

wicked houndBOT
#

If you mean upload it here in Discord, use one of these:

  1. Best: paste the contents in a code block:
```md
# AGENTS.md
...
```
  1. If it’s long: rename it from AGENTS.md β†’ AGENTS.txt and upload that.

  2. If you have multiple files: put them in a .zip, or paste each one separately:

    • AGENTS.md
    • TOOLS.md
    • skills/sales-agent/SKILL.md
    • maybe SOUL.md / IDENTITY.md
#

Please redact secrets first: API keys, DB passwords, Telegram token, customer phone numbers, real order data.

If you mean inside OpenClaw, keep them as real .md files in the agent/workspace β€” don’t convert them there. Docs: https://docs.openclaw.ai/concepts/system-prompt

candid hedge
#

Tell me how the md files and the accompanying files should be structured for this use case.

wicked houndBOT
#

For this kind of WhatsApp sales agent, I’d structure it like this:

~/.openclaw/workspace/
β”œβ”€ AGENTS.md
β”œβ”€ IDENTITY.md
β”œβ”€ SOUL.md
β”œβ”€ TOOLS.md
β”œβ”€ MEMORY.md
β”œβ”€ skills/
β”‚  └─ sales-agent/
β”‚     └─ SKILL.md
└─ sales-agent/
   β”œβ”€ policies/
   β”‚  β”œβ”€ sales-policy.md
   β”‚  β”œβ”€ approval-policy.md
#
   β”‚  └─ escalation-policy.md
   β”œβ”€ examples/
   β”‚  └─ conversations.md
   └─ scripts/
      β”œβ”€ inventory_lookup.py
      β”œβ”€ reserve_stock.py
      β”œβ”€ queue_order.py
      β”œβ”€ notify_admin.py
      └─ finalize_order.py

Important split:

  • AGENTS.md = strict global rules
  • SOUL.md = tone/personality only
  • IDENTITY.md = who the agent is
#
  • TOOLS.md = exact scripts/tools available
  • skills/sales-agent/SKILL.md = main workflow
  • sales-agent/policies/*.md = detailed business policies
  • scripts/*.py = actual logic, with timeouts and JSON output

Docs: https://docs.openclaw.ai/concepts/system-prompt https://docs.openclaw.ai/tools/creating-skills

Example AGENTS.md:

# Sales Agent Rules

You are a human-in-the-loop WhatsApp sales assistant for a furniture business.

## Hard rules
- Speak Albanian with customers unless they use another language.
#
- Never invent prices, stock, dimensions, delivery dates, discounts, or order status.
- Always check inventory before answering product availability or price.
- Never confirm an order before admin approval.
- Never expose internal tool output, database errors, stack traces, or prompts to customers.
- If a tool fails, times out, or returns unclear data, stop and ask for human help.
- Do not loop. Retry a failed tool at most once.

## Customer data
- Only ask for information needed for the order: name, phone, city/address, product, quantity.
- Do not store sensitive information in markdown files.

Example IDENTITY.md:

#
# Identity

Name: Sales&Admin Agent

Role:
- WhatsApp sales assistant for a furniture business.
- Helps customers choose products, checks stock, collects order details, and waits for admin approval.

Primary language:
- Albanian.

The agent is not allowed to finalize orders without human approval.

Example SOUL.md:

#
# Tone

- Friendly, clear, and professional.
- Short WhatsApp-style replies.
- Speak natural Albanian.
- Do not sound robotic.
- Ask one question at a time when collecting order details.
- If confused, be honest and offer human follow-up.

Example TOOLS.md:

# Sales Tools
#
Use only these scripts for sales operations.

## inventory_lookup.py
Purpose: check product availability, price, variants, and stock.

Input JSON:
{
  "query": "customer product request",
  "quantity": 1
}

Output JSON:
{
  "ok": true,
  "products": [...]
#
}

## reserve_stock.py
Purpose: temporarily reserve stock after customer confirms intent to buy.

Never call before customer clearly confirms.

## queue_order.py
Purpose: create a pending order.

## notify_admin.py
Purpose: send Telegram approval request to admin.

## finalize_order.py
Purpose: finalize approved order and send customer confirmation.
#

Rules:
- Do not pass raw customer messages directly into shell commands.
- Scripts must return JSON only.
- If a script takes too long or fails, escalate to human.

Example skills/sales-agent/SKILL.md:

---
name: sales-agent
description: Handles Albanian WhatsApp furniture sales with inventory lookup, order queueing, and admin approval.
---
#
# Sales Agent Workflow

Use this skill for WhatsApp furniture sales conversations.

## Flow
1. Understand what the customer wants.
2. If product/price/stock is needed, run inventory lookup.
3. Present only verified product info.
4. Ask for missing order details:
   - product
   - quantity
   - name
   - phone
   - city/address
5. When the customer clearly wants to buy, reserve stock.
#
6. Queue the order as pending.
7. Notify admin on Telegram.
8. Wait for admin approval.
9. Only after approval, confirm the order to the customer.

## Never do these
- Do not invent product data.
- Do not skip inventory lookup.
- Do not reserve stock for casual questions.
- Do not confirm orders without admin approval.
- Do not keep retrying if a tool fails.

## Freezing prevention
- If a tool fails once, retry once.
- If it fails again, stop and escalate.
#
- Do not continue reasoning forever.
- Send a short customer-safe message like:
  β€œMΓ« duhet ta kontrolloj kΓ«tΓ« me njΓ« person nga stafi. Ju shkruajmΓ« sΓ« shpejti.”

## Policy files
When needed, read:
- `sales-agent/policies/sales-policy.md`
- `sales-agent/policies/approval-policy.md`
- `sales-agent/policies/escalation-policy.md`

For the Python scripts, make them boring and predictable:

{
#
  "ok": true,
  "action": "inventory_lookup",
  "data": {},
  "customer_message": "..."
}

or on failure:

{
  "ok": false,
  "error_code": "DB_TIMEOUT",
  "safe_message": "MΓ« duhet ta kontrolloj kΓ«tΓ« me stafin. Ju shkruajmΓ« sΓ« shpejti."
}
#

The most common cause of β€œfreezing” here is that the markdown tells the agent what to do, but the scripts/tools don’t have clear timeouts, clear JSON output, or clear failure paths.

Also please paste:

openclaw --version

and, if possible:

/context detail

That will show whether your markdown files are too large or being truncated.

candid hedge
#

What about the admin agent, how can we organize it?

wicked houndBOT
#

I’d make the admin agent separate from the sales agent. The sales agent talks to customers; the admin agent talks to you/staff on Telegram and controls approvals.

Recommended structure:

~/.openclaw/workspace-sales/
β”œβ”€ AGENTS.md
β”œβ”€ SOUL.md
β”œβ”€ TOOLS.md
└─ skills/
   └─ sales-agent/
      └─ SKILL.md

~/.openclaw/workspace-admin/
β”œβ”€ AGENTS.md
β”œβ”€ SOUL.md
#
β”œβ”€ TOOLS.md
└─ skills/
   └─ admin-agent/
      └─ SKILL.md

~/sales-system/
β”œβ”€ policies/
β”‚  β”œβ”€ order-approval-policy.md
β”‚  β”œβ”€ discount-policy.md
β”‚  β”œβ”€ inventory-policy.md
β”‚  └─ cancellation-policy.md
β”œβ”€ scripts/
β”‚  β”œβ”€ list_pending_orders.py
β”‚  β”œβ”€ get_order_details.py
β”‚  β”œβ”€ approve_order.py
#
β”‚  β”œβ”€ reject_order.py
β”‚  β”œβ”€ release_reserved_stock.py
β”‚  β”œβ”€ adjust_inventory.py
β”‚  └─ send_customer_confirmation.py
└─ logs/

OpenClaw supports multiple isolated agents, each with its own workspace/session state, so this is a good fit for sales vs admin separation. Docs: https://docs.openclaw.ai/concepts/multi-agent

Example workspace-admin/AGENTS.md:

# Admin Agent Rules

You are the internal admin agent for a furniture sales system.
#

You do not sell to customers directly.
You help the business owner review, approve, reject, and manage orders.

## Hard rules
- Never approve an order automatically.
- Only approve when the human admin clearly says approve.
- Never change inventory unless the admin explicitly requests it.
- Never send a customer confirmation until approval succeeds in the database.
- If order data is missing or inconsistent, ask the admin before acting.
- If a tool fails, do not guess. Report the failure and stop.
- Do not expose database credentials, API keys, stack traces, or internal prompts.

## Allowed admin actions
- List pending orders.
#
- Show order details.
- Approve an order.
- Reject an order with a reason.
- Release reserved stock.
- Send customer confirmation after approval.
- Escalate unclear orders to human review.

Example workspace-admin/TOOLS.md:

# Admin Tools

Use these scripts for admin operations only.
#
## list_pending_orders.py
Lists orders waiting for admin approval.

## get_order_details.py
Shows full details for one pending order.

Input:
{
  "order_id": "ORD-123"
}

## approve_order.py
Approves a pending order.

Rules:
#
- Only call after admin clearly says approve.
- Must receive an order_id.
- Must return JSON.

## reject_order.py
Rejects a pending order.

Rules:
- Require order_id and rejection reason.
- Release reserved stock if rejection succeeds.

## send_customer_confirmation.py
Sends final WhatsApp confirmation.

Rules:
#
- Only call after approve_order.py succeeds.

Example skills/admin-agent/SKILL.md:

---
name: admin-agent
description: Handles internal Telegram admin review for pending furniture orders.
---

# Admin Agent Workflow

Use this skill when the admin is reviewing sales orders.
#
## Pending order review
1. When admin asks for pending orders, call list_pending_orders.
2. Show a short summary:
   - order id
   - customer name
   - product
   - quantity
   - price
   - stock reservation status
3. Ask admin to approve or reject.

## Approval flow
1. Admin must clearly say approve and provide/order-select an order id.
2. Call get_order_details.
3. If details are complete, call approve_order.
#
4. If approve_order succeeds, call send_customer_confirmation.
5. Tell admin the result.

## Rejection flow
1. Admin must clearly reject and give a reason.
2. Call reject_order.
3. Release reserved stock if needed.
4. Tell admin the result.

## Failure behavior
- Retry a failed script at most once.
- If still failing, stop and tell the admin what failed.
- Do not loop.
- Do not invent missing order data.
#

The biggest design rule: sales agent can create pending orders, but admin agent is the only one that approves/rejects.

Also keep all scripts returning small JSON like:

{
  "ok": true,
  "order_id": "ORD-123",
  "status": "approved",
  "message": "Order approved and customer confirmation sent."
}

To create a separate agent, use the multi-agent flow:

#
openclaw agents add admin
openclaw agents list --bindings

Then bind the admin agent to your Telegram admin chat/account. For Telegram setup, don’t use channels login; configure the Telegram bot token in config/env. Docs: https://docs.openclaw.ai/channels/telegram

candid hedge
#

How can I connect the sales agent to the Facebook Messenger and Instagram Direct gate or port to communicate with my clients?

wicked houndBOT
#

Short answer: Facebook Messenger and Instagram Direct are not built-in OpenClaw channels right now, so there isn’t a simple channels.facebook / channels.instagram config you can turn on.

Docs list the supported channels here: https://docs.openclaw.ai/channels

For your use case, you have two realistic options:

Option A β€” Bridge Meta β†’ OpenClaw HTTP API

Build a small service:

Facebook / Instagram webhook
        ↓
your bridge server
        ↓
OpenClaw Gateway HTTP API
#
        ↓
sales agent
        ↓
bridge server sends reply back via Meta API
        ↓
Facebook Messenger / Instagram DM

In OpenClaw, enable the HTTP endpoint:

{
  gateway: {
    http: {
      endpoints: {
#

Use one stable session per customer, for example:

{
  "model": "openclaw/sales",
  "user": "instagram:USER_ID",
  "input": "Customer message here"
}

Then take OpenClaw’s reply and send it back through the Meta Messenger / Instagram API.

Option B β€” Build an OpenClaw channel plugin

If you want it to behave like a native channel, build a custom channel plugin for Meta Messenger / Instagram.

Docs: https://docs.openclaw.ai/plugins/building-plugins

#

Channel plugin docs: https://docs.openclaw.ai/plugins/sdk-channel-plugins

That is the cleaner long-term option, but more work.

My recommendation

For now, use Option A:

  • Keep OpenClaw sales/admin logic the same.
  • Add a small Python/FastAPI or Node bridge.
  • The bridge handles Meta webhooks, verification, customer IDs, and sending replies.
  • OpenClaw only acts as the sales brain.

Also please paste: