useDocyrusInstantMessageComposer
Wires the native InstantMessageComposer to the Docyrus SMS and WhatsApp messaging API.
Installation
pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-instant-message-composerpnpm add @tanstack/react-query @docyrus/api-clientA verbatim port of the web hook. It loads GET /v1/messaging/sms/accounts and GET /v1/messaging/whatsapp/accounts (only for the availableChannels), auto-selects the first account per channel, and sends through POST …/sms/accounts/{accountId}/send or …/whatsapp/accounts/{accountId}/send. WhatsApp supports text and pre-approved template messages. A QueryClientProvider must be mounted above it.
Usage
import { InstantMessageComposer } from '@/components/docyrus-native/instant-message-composer';
import { useDocyrusInstantMessageComposer } from '@/hooks/docyrus-native/use-docyrus-instant-message-composer';
const { composerProps } = useDocyrusInstantMessageComposer({ client, initialRecipients: ['+905551234567'] });
<InstantMessageComposer {...composerProps} />// WhatsApp template
await send({ channel: 'whatsapp', type: 'template', templateName: 'order_shipped', templateLanguage: 'en_US', templateParams: ['#1042'] });API Reference
UseDocyrusInstantMessageComposerOptions
| Option | Type | Default | Description |
|---|---|---|---|
client | RestApiClient | - | Authenticated REST client (required) |
initialChannel | 'sms' | 'whatsapp' | 'sms' | Initial channel |
availableChannels | ReadonlyArray<InstantMessageChannel> | ['sms', 'whatsapp'] | Channels offered (and queried) |
initialRecipients | string[] | [] | Initial recipients |
initialBody | string | '' | Initial body |
initialSmsAccountId / initialWhatsAppAccountId | string | first account | Accounts to preselect |
resetOnSendSuccess | boolean | true | Clear recipients / body / attachments after a send |
enabled | boolean | true | Toggle the queries |
defaultFrom | string | - | Default sender override |
defaultPhoneNumberId | string | - | Default Meta WhatsApp Cloud phone number id |
listSmsAccountsEndpoint / listWhatsAppAccountsEndpoint | string | /v1/messaging/{sms,whatsapp}/accounts | Account endpoints |
sendSmsEndpoint / sendWhatsAppEndpoint | string | …/accounts/{accountId}/send | Send endpoints |
UseDocyrusInstantMessageComposerResult
| Field | Type | Description |
|---|---|---|
composerProps | Pick<InstantMessageComposerProps, …> | channel, availableChannels, recipients, body, attachments + handlers, onSend, sending |
channel / setChannel | Active channel | |
smsAccounts / whatsAppAccounts | DocyrusSmsAccount[] / DocyrusWhatsAppAccount[] | Account DTOs |
selectedSmsAccount / selectedWhatsAppAccount / selectedAccountId | Selection | |
setSelectedSmsAccountId / setSelectedWhatsAppAccountId | (id: string) => void | Change the account |
isLoadingAccounts / accountsError / refetchAccounts | Accounts query state | |
recipients / body / attachments + setters | Composer state | |
send | (overrides?: DocyrusInstantMessageSendOverrides) => Promise<DocyrusInstantMessageSendResult> | Send |
isSending / sendError / lastSendResult / reset | Mutation state |
Types
| Type | Description |
|---|---|
DocyrusSmsAccount / DocyrusWhatsAppAccount | Account DTOs |
DocyrusInstantMessageSendOverrides | channel, to, body, from, accountId, type, phoneNumberId, templateName, templateLanguage, templateParams |
DocyrusInstantMessageSendResult | { messageId, provider, accepted, rejected } |
WhatsAppMessageType | 'text' | 'template' |
useDocyrusFormView
Create, edit and view forms bound to a Docyrus data source on React Native. Loads the schema, record and options, uploads files to Docyrus storage and creates or updates the record through the shared form-view engine.
useDocyrusInventory
Shared app-utils inventory cache for Docyrus metadata (apps, data sources with fields, enums, views and forms, users, brands, preferences) plus a post-sign-in warm-up hook that drives a loading screen.