@ministerjs/chatwoot
v0.1.0
Published
Framework-agnostic Chatwoot client used to send text messages, send WhatsApp templates through Chatwoot, list inboxes, and query conversations.
Readme
@ministerjs/chatwoot
Framework-agnostic Chatwoot client used to send text messages, send WhatsApp templates through Chatwoot, list inboxes, and query conversations.
Usage
import { ChatWoot } from "@ministerjs/chatwoot";
const chatwoot = new ChatWoot({
baseUrl: process.env.CHATWOOT_API_BASE_URL!,
token: process.env.CHATWOOT_TOKEN!,
accountId: Number(process.env.CHATWOOT_ACCOUNT_ID!),
inboxId: Number(process.env.CHATWOOT_INBOX_ID!),
whatsAppBusiness: {
id: Number(process.env.WABA_ID!),
baseUrl: process.env.META_GRAPH_URL!,
token: process.env.META_GRAPH_API_TOKEN!,
},
defaultCountryCode: "55",
});
await chatwoot.sendMessage({
contact: {
name: "Contato Teste",
phone: "(66) 9965-0063",
},
message: "Mensagem de teste",
});WhatsApp Templates
await chatwoot.sendWhatsAppTemplate({
contact: {
name: "Maria",
phone: "+556699650063",
},
template: {
name: "formulario_projeto",
params: {
nome: "Maria",
link: "https://example.com",
},
},
});sendWhatsAppTemplate resolves the template metadata from the configured WhatsApp Business Account before creating the outgoing Chatwoot message.
Utilities
import { formatPhoneNumber } from "@ministerjs/chatwoot";
formatPhoneNumber("(66) 99965-0063", "55"); // "+556699650063"Migration From @repo/chatwoot
The main compatibility names were preserved:
ChatWootWhatsAppBusinessAccountChatWootConfigMessageOptionsTemplateMessageOptions
Replace imports from @repo/chatwoot with @ministerjs/chatwoot.
