npm package: @idliapam/chutney-js
Description: JavaScript SDK for AI Commerce OS — WhatsApp, invoicing, inventory, loyalty, support APIs
Author: Idliapam
Latest version: 1.1.0

# @idliapam/chutney-js

**The JavaScript SDK for AI Commerce OS. One SDK for WhatsApp messaging, invoicing, inventory, loyalty, support, and AI — built for Indian commerce.**

[![npm version](https://img.shields.io/npm/v/@idliapam/chutney-js.svg)](https://www.npmjs.com/package/@idliapam/chutney-js)
[![License: MIT](https://img.shields.io/badge/License-MIT-violet.svg)](https://opensource.org/licenses/MIT)

---

## The Problem

Building commerce features for Indian businesses means integrating 10+ separate APIs:
- WhatsApp Business API (Meta) — for messaging
- Razorpay/Cashfree — for payments
- Brevo/SendGrid — for emails
- Freshdesk/Zendesk — for support
- Custom solutions — for invoicing, inventory, loyalty

Each has different auth, different SDKs, different docs. You spend months gluing them together.

## The Solution

Chutney is a single SDK that gives you all commerce operations in one API call:

```javascript
const client = new Chutney({ apiKey: 'chutney_sk_xxx', brandId: 'brand_xxx' });

// One line: send WhatsApp + create order + generate invoice + award loyalty points
await client.whatsapp.send({ to: '+919876543210', message: 'Order confirmed!' });
await client.orders.create({ customerName: 'Priya', items: [{...}] });
await client.invoices.create({ customerName: 'Priya', items: [{...}] });
await client.loyalty.awardPoints({ phone: '+919876543210', points: 100, reason: 'Purchase' });
```

---

## Install

```bash
npm install @idliapam/chutney-js
```

---

## Quick Start

```javascript
import { Chutney } from '@idliapam/chutney-js';

const client = new Chutney({
  apiKey: 'chutney_sk_xxx',
  brandId: 'brand_xxx',
});

// Send WhatsApp message
await client.whatsapp.send({
  to: '+919876543210',
  message: 'Your order #4521 has been shipped!'
});

// Create GST invoice
const invoice = await client.invoices.create({
  customerName: 'Priya Sharma',
  customerEmail: 'priya@example.com',
  items: [
    { description: 'Scented Candle', quantity: 2, price: 499 },
    { description: 'Gift Box', quantity: 1, price: 199 },
  ],
});

// Check inventory
const { products } = await client.inventory.list({ lowStockOnly: true });

// Enroll customer in loyalty program
await client.loyalty.enroll({
  customerName: 'Priya Sharma',
  customerPhone: '+919876543210',
});

// Award loyalty points
await client.loyalty.awardPoints({
  phone: '+919876543210',
  points: 100,
  reason: 'Purchase',
});

// Create support ticket
await client.support.createTicket({
  subject: 'Wrong item received',
  description: 'Ordered red candle but received blue',
  customerEmail: 'priya@example.com',
});

// Get AI suggestion for ticket
const suggestion = await client.support.getAISuggestion('TICK-001');

// Ask AI Copilot anything
const answer = await client.ai.ask('What were my top selling products last month?');
```

---

## Available APIs

| Module | Methods | What It Does |
|--------|---------|-------------|
| `client.whatsapp` | `send()`, `getConversations()`, `getTemplates()` | Send WhatsApp messages, manage conversations |
| `client.invoices` | `create()`, `list()`, `markPaid()`, `send()` | GST invoicing with email/WhatsApp delivery |
| `client.inventory` | `list()`, `create()`, `updateStock()`, `dashboard()` | Product catalog, stock movements, reorder alerts |
| `client.loyalty` | `enroll()`, `awardPoints()`, `lookup()`, `getProgram()` | Membership cards, points, tiers, rewards |
| `client.support` | `createTicket()`, `listTickets()`, `getAISuggestion()`, `resolve()` | Support tickets with AI-powered resolution |
| `client.leads` | `create()`, `list()`, `convert()` | Lead management and pipeline |
| `client.orders` | `create()`, `list()`, `fulfill()` | Order management with fulfillment |
| `client.ai` | `ask()` | AI Copilot — ask anything about your business data |

---

## India-First Features

- **INR currency** throughout (not USD)
- **GST invoicing** with 18% tax calculation
- **UPI payment tracking** (cash, UPI, bank transfer, card)
- **WhatsApp-first** communication (India's #1 channel)
- **Regional language AI** (Hindi support coming soon)
- **Meta WhatsApp TSP** — official Technology Solution Provider

---

## Configuration

```javascript
const client = new Chutney({
  apiKey: 'chutney_sk_xxx',     // Get from dashboard
  brandId: 'brand_xxx',         // Your brand identifier
  baseUrl: 'https://...',       // Custom API URL (optional)
});
```

---

## Error Handling

```javascript
try {
  await client.whatsapp.send({ to: '+91...', message: 'Hello' });
} catch (error) {
  console.error(error.message); // "HTTP 400: Invalid phone number"
}
```

All errors throw with a descriptive message from the API.

---

## Use Cases

- **D2C Brands** — Manage entire retail operations via API
- **Agencies** — Build client dashboards powered by Chutney backend
- **Developers** — Add commerce features to any app in minutes
- **Automation** — Connect Chutney to Zapier, n8n, or custom workflows
- **Chatbots** — Power WhatsApp/Telegram bots with commerce capabilities
- **Mobile Apps** — React Native / Flutter apps with full commerce backend

---

## Python SDK

Also available for Python:
```bash
pip install idliappam
```
```python
from idliappam import Chutney
client = Chutney(api_key='chutney_sk_xxx', brand_id='brand_xxx')
client.whatsapp.send(to='+919876543210', message='Hello!')
```

See: [github.com/Ankitajainkuniya/chutney-python](https://github.com/Ankitajainkuniya/chutney-python)

---

## Contributing

We welcome contributions! Open an issue or PR on [GitHub](https://github.com/Ankitajainkuniya/chutney-js).

## Support

- Documentation: [docs.idliapam.in](https://docs.idliapam.in)
- Issues: [GitHub Issues](https://github.com/Ankitajainkuniya/chutney-js/issues)
- Email: hello@idliapam.in

## License

MIT - see [LICENSE](LICENSE)

---

Built by [Idliapam](https://idliapam.in) — the unified AI platform for Indian commerce.