💡
Tip: You do not need to build this yourself. Workspace → AI Support runs an assistant on SellMyCode with your own Claude, ChatGPT or Gemini key: paste the key, choose Draft only or Auto reply, add FAQs per item, and set spending limits. It is free — you only pay your AI provider. The rest of this page is for authors who want to run their own assistant through the API.
#How it fits together
- A buyer writes. We POST
ticket.createdorticket.repliedto your webhook URL, signed, within seconds. - Your assistant reads the case. It fetches
GET /api/tickets/{id}for the whole conversation, plus your docs, changelog and FAQ. - It answers or hands over. A confident answer goes out with
POST /api/tickets/{id}/replies. Anything else becomes an internal note, and the ticket stays in your inbox as "needs reply".
#Set it up
- Create a token with only
tickets:read,tickets:replyandtickets:note(additems:readif the assistant should look up your items). Store it in~/.config/sellmycode/token— never in code. - In Workspace → Settings → API → Webhooks, add your assistant's HTTPS URL with the events
ticket.createdandticket.replied, and keep the signing secret. - In your handler, verify the signature, answer 200 at once, and do the work in the background.
#Rules worth giving your assistant
- Answer only from your documentation and changelog; when unsure, write an internal note instead of guessing.
- Never ask for passwords, server logins or payment details in a ticket.
- Check
purchase.support_active— when support has ended, explain how to renew instead of debugging. - Leave refunds, licence disputes and anything an administrator joined (
escalated: true) to you. - Sign replies so buyers know they may talk to an assistant, if your policy requires it.
#Example handler
# Flask — on ticket.created / ticket.replied
import hmac, hashlib, time, json, requests
from flask import Flask, request
TOKEN = open("/home/me/.config/sellmycode/token").read().strip()
SECRET = "whsec_..."
API = "https://sellmycode.net/api"
H = {"Authorization": f"Bearer {TOKEN}"}
@app.post("/hooks/sellmycode")
def hook():
sig = dict(p.split("=", 1) for p in request.headers.get("X-SMC-Signature", "").split(",") if "=" in p)
body = request.get_data()
good = hmac.compare_digest(hmac.new(SECRET.encode(), (sig.get("t", "") + ".").encode() + body, hashlib.sha256).hexdigest(), sig.get("v1", ""))
if not good or abs(time.time() - float(sig.get("t", 0))) > 300:
return "", 400
event = json.loads(body)
if event["event"] in ("ticket.created", "ticket.replied"):
queue.enqueue(handle_ticket, event["data"]["ticket_id"]) # do the work later
return "", 200
def handle_ticket(ticket_id):
t = requests.get(f"{API}/tickets/{ticket_id}", headers=H, timeout=20).json()["ticket"]
if t["state"] != "needs_reply" or t["escalated"]:
return
answer, confident = my_ai_answer(t) # your model + your docs
if confident:
requests.post(f"{API}/tickets/{ticket_id}/replies", headers=H, json={"body": answer}, timeout=20)
else:
requests.post(f"{API}/tickets/{ticket_id}/notes", headers=H, json={"body": "AI draft:\n" + answer}, timeout=20)
Every reply the assistant sends is a reply from you. The buyer sees it in their inbox and can always ask for a person; you see the whole thread, notes included, in Workspace → Support.
Developers