Pakai SDK dengan Bantuan AI
Salin prompt siap pakai ke ChatGPT, Claude, Cursor, atau Copilot supaya AI menulis kode WatZap SDK yang benar.
Kalau Kamu belum terbiasa coding, AI assistant seperti ChatGPT, Claude, Cursor, atau GitHub Copilot bisa membantu menuliskan kode integrasi. Masalahnya, AI sering "mengarang" nama fungsi yang sebenarnya tidak ada.
Prompt di bawah ini berisi daftar lengkap fungsi WatZap SDK, sehingga AI hanya memakai fungsi yang benar-benar tersedia.
Cara Pakai
Salin seluruh prompt di bawah (klik ikon salin di pojok kanan atas kotak kode).
Tempel ke AI assistant pilihan Kamu.
Ganti bagian
<JELASKAN APA YANG INGIN KAMU BUAT>di baris terakhir dengan kebutuhan Kamu. Boleh ditulis dalam Bahasa Indonesia. Semakin jelas, semakin bagus hasilnya.
Contoh isian baris terakhir:
Setiap ada pesanan baru di website saya, kirim template WABA
pesanan_baruke nomor pembeli berisi nama dan nomor pesanan. Backend saya memakai Express.
Prompt
You are helping me integrate WatZap into my app with the official SDK @watzapid/sdk (TypeScript/JavaScript, Node.js 18+). Use only the methods and options listed here. Do not invent others.
SETUP
- Install: npm install @watzapid/sdk
- ESM: import { WatZap } from '@watzapid/sdk' CommonJS: const { WatZap } = require('@watzapid/sdk')
- const wz = new WatZap() // reads the API key from the WATZAP_API_KEY environment variable
- Server-side only. Never put the API key in frontend code or in the repository.
- List methods return a PagedList: `await` it for one page ({ items, page, perPage, total, hasNextPage }), or `for await (const item of ...)` for every item.
WHATSAPP: WABA (official). Sends return Promise<{ id, raw }>; id is the Meta message ID (wamid).
- wz.whatsapp.messages.sendText({ to, text })
- wz.whatsapp.messages.sendTemplate({ to, template, language?, variables?, header?, buttons?, otpCode? })
- variables: an object for NAMED templates, an array for POSITIONAL templates ({{1}}, {{2}})
- header: { url, filename? }; buttons: { urlSuffix?: string | { [buttonIndex]: string }, couponCode?: string }
- wz.whatsapp.messages.sendImage|sendDocument|sendVideo({ to, url, caption? }); sendAudio({ to, url }); react({ to, messageId, emoji })
- wz.whatsapp.messages.sendButtons({ to, body, buttons: [{ id, title }] (1-3, title max 20 bytes), header?, footer? })
- wz.whatsapp.messages.sendList({ to, body, buttonText, sections: [{ title?, rows: [{ id, title, description? }] }] })
- wz.whatsapp.messages.sendLocation({ to, latitude, longitude, name?, address? }); sendContacts({ to, contacts }); sendRaw(payload)
- wz.whatsapp.messages.get(id) / status(id) / list({ status?, phone?, page?, perPage? }) / stats()
- wz.whatsapp.templates.list({ wabaId?, status?, search? }) / get(templateId | { name, wabaId, language? }) / status(ref) / create({ name, category, language, components }) / delete(ref) / sync()
- wz.whatsapp.webhook(wabaId).set(url) / get() / unset()
- Text and media only reach users who messaged the business in the last 24 hours. Otherwise use sendTemplate.
- Do not use wz.whatsapp.broadcasts to send campaigns: the server does not process broadcasts created through the API yet.
WHATSAPP: UNOFFICIAL. numberKey is the 16-character key of a linked number. Sends return { message, senderNumber, raw } with no message ID.
- const device = wz.unofficial.device(numberKey)
- device.messages.sendText({ to, text }) / sendImage({ to, url, caption? }) / sendFile({ to, url })
- device.groups.list() / device.groups.sendText({ groupId, text }) / sendImage({ groupId, url, caption? }) / sendFile({ groupId, url })
- device.validateNumber(phone); device.webhook.set(url) / get() / unset()
- wz.unofficial.conversations.list() / get(id) / messages(id) / markRead(id) / archive(id, archived?)
SHARED
- wz.senders.list() returns every WABA and Unofficial number with its numberKey / wabaId and status
- wz.contacts.list({ listId? }) / get({ contactId } | { phone } | { externalId }) / upsert({ listId, phone?, externalId?, name?, source?, status? }) / delete(contactId) / optIn({ phone }) / optOut({ phone })
- upsert overwrites fields you leave out with empty values: always send every field you want to keep
- opt-out is only recorded: check it yourself before sending
- wz.lists.list() / get(listId) / create({ name, customFields? }) / update(listId, {...}) / delete(listId)
- wz.lists.subscribers.list(listId, { channel? }) / get(listId, id) / upsert(listId, { phone?, email?, externalId?, name?, customFields? }) / delete(listId, id) / bulkUpsert(listId, items) / sync(listId, items, { markMissingInactive? })
- wz.media.uploadUrl({ url }) / list() / get(id) / download(id) / delete(id)
- wz.automations.bots() / rules() / n8nConfig() / n8nLogs() / n8nStats()
PHONE NUMBERS: 08xxx, 62xxx and +62xxx are all accepted and normalized. Use a leading + for non-Indonesian numbers.
ERRORS
- Every error extends WatZapError and has name, message, code, httpStatus, response, mayHaveBeenProcessed; RateLimitError also has retryAfterSeconds.
- Classes: ValidationError (bad input, checked by the SDK or the server), AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableError, RateLimitError, ProviderError, InternalServerError, APIConnectionError, APITimeoutError, APIUserAbortError.
- The SDK already retries whenever it is safe. Do not wrap WhatsApp sends in your own retry loop.
- If err.mayHaveBeenProcessed is true, the message may already have been delivered: check wz.whatsapp.messages.status(id) or log it; do not resend automatically.
Now write the code for this, and explain it in Bahasa Indonesia: <JELASKAN APA YANG INGIN KAMU BUAT>Kalau kode dari AI menghasilkan error, salin pesan error-nya kembali ke AI, atau cocokkan dengan tabel di Menangani Error.