import type { CannedReply, CreateCannedReplyInput, ListCannedRepliesQuery, Paginated, UpdateCannedReplyInput } from '../../types'; import type { HttpClient } from '../../http'; /** * Canned replies: message payloads an agent sends into a chat without retyping * them. * * Two kinds. A `CANNED` reply sends every message it holds, as stored, in order, * the moment it is picked -- so a three-message reply is three messages on the * contact's phone from one keystroke. A `QUICK` reply drops its text into the * agent's composer to edit first, which is why it holds exactly one text message * and nothing else. * * ```ts * await crm.cannedReplies.create({ * name: 'price list', * type: 'CANNED', * channel: 'whatsapp', * messages: [ * { version: '2', whatsapp_api: { type: 'text', text: { body: 'Here you go' } } }, * { version: '2', whatsapp_api: { * type: 'document', * document: { link: 'https://.../prices.pdf', filename: 'prices.pdf' } } }, * ], * }); * ``` * * The payload under `whatsapp_api` is the same object `inbox.messages.send()` * takes as `content`, which is the point: picking a reply is sending its * payloads, with no translation step in between. * * Variable placeholders in a body are stored literally and substituted by the * sender against the contact in front of the agent. There is no contact at the * time a reply is written, so nothing is substituted here. */ export declare class CannedReplies { private readonly http; constructor(http: HttpClient); /** * `GET /v1/audience/canned-replies` -- offset paginated, newest first, with * `messages` included on every row. * * Query: `page` (default 1), `rows` (1-100, default 25), `search` (matches the * name, case-insensitive, substring, the term escaped), `type` (`CANNED` | * `QUICK`), `channel` (a channel *type*, e.g. `whatsapp` -- not a channel id). * * To count without fetching, ask for `rows: 1` and read `pagination.total`. * * Scope: `canned_replies:read`. */ list(query?: Partial): Promise>; /** * `GET /v1/audience/canned-replies/:reply` -- by **id or name**. * * A 24-hex-character value is read as an id, anything else as a name. Names are * unique per account, which is what makes addressing by the name an agent typed * safe. 404 `not_found` if it is not the caller's. * * Scope: `canned_replies:read`. */ get(ref: string): Promise; /** * `POST /v1/audience/canned-replies` -- 201 with the created reply. * * Body: `name` (1-120 chars, unique per account), `type`, `channel` (default * `whatsapp`), `messages` (1-10, each `{ version: '2', whatsapp_api, internal? }`). * * Errors: 409 `conflict` if the name is taken. 422 `invalid_canned_reply` if a * `QUICK` reply holds more than one message or a non-text one -- which legacy * accepted and the panel then refused to use. * * Scope: `canned_replies:write`. */ create(input: CreateCannedReplyInput): Promise; /** * `PATCH /v1/audience/canned-replies/:reply` -- by id or name, any subset of * the create body. * * `messages` is replaced whole, never merged: send the array you want stored. * Renaming works (it silently did not in legacy, which `$set` only `messages`). * * Errors: 404 `not_found`; 409 `conflict` on a rename into a taken name; 422 * `invalid_canned_reply` if the *merged* result breaks the `QUICK` rule -- so * flipping a three-message reply to `QUICK` is refused, while renaming one that * already breaks the rule is not. * * Scope: `canned_replies:write`. */ update(ref: string, input: UpdateCannedReplyInput): Promise; /** * `DELETE /v1/audience/canned-replies/:reply` -- by id or name. 204, no body. * * Scope: `canned_replies:write`. */ delete(ref: string): Promise; }