meta whatsapp chat
This commit is contained in:
parent
54f75387eb
commit
5ced0d0812
10 changed files with 1015 additions and 25 deletions
|
|
@ -1138,6 +1138,8 @@ export type WhatsAppPhoneAsset = {
|
|||
quality: string | null
|
||||
status: string
|
||||
code_verification_status: string | null
|
||||
needs_otp?: boolean
|
||||
needs_registration?: boolean
|
||||
}
|
||||
|
||||
export type WhatsAppAccount = {
|
||||
|
|
@ -1188,6 +1190,36 @@ export type WhatsAppAccountLogs = {
|
|||
events: { id: string; field: string; event_type: string; from_wa_id: string | null; status: string | null; created_at: string }[]
|
||||
}
|
||||
|
||||
export type CustomerWhatsAppMessage = {
|
||||
id: string
|
||||
direction: 'inbound' | 'outbound'
|
||||
wa_message_id: string | null
|
||||
from: string
|
||||
to: string
|
||||
body: string | null
|
||||
message_type: string
|
||||
status: string
|
||||
contact_name?: string | null
|
||||
media?: { id?: string; mime_type?: string; caption?: string; filename?: string } | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type CustomerWhatsAppSend = {
|
||||
to: string
|
||||
message_type?: string
|
||||
text?: string
|
||||
reply_to?: string
|
||||
template_name?: string
|
||||
template_language?: string
|
||||
media_link?: string
|
||||
media_caption?: string
|
||||
media_filename?: string
|
||||
interactive_body?: string
|
||||
interactive_buttons?: { id: string; title: string }[]
|
||||
reaction_message_id?: string
|
||||
reaction_emoji?: string
|
||||
}
|
||||
|
||||
export type WhatsAppWebhookEvent = {
|
||||
id: string
|
||||
waba_id: string | null
|
||||
|
|
@ -1222,6 +1254,18 @@ export const whatsappApi = {
|
|||
jsonRequest<WhatsAppAccount>(`/api/v1/whatsapp/accounts/${accountId}/refresh`, { method: 'POST' }),
|
||||
disconnectAccount: (accountId: string) =>
|
||||
jsonRequest<WhatsAppAccount>(`/api/v1/whatsapp/accounts/${accountId}/disconnect`, { method: 'POST' }),
|
||||
registerPhone: (accountId: string, phoneId: string, pin?: string) =>
|
||||
jsonRequest<WhatsAppAccount>(`/api/v1/whatsapp/accounts/${accountId}/phones/${phoneId}/register`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ pin: pin || null }),
|
||||
}),
|
||||
messages: (accountId: string) =>
|
||||
jsonRequest<CustomerWhatsAppMessage[]>(`/api/v1/whatsapp/accounts/${accountId}/messages`),
|
||||
sendAccountMessage: (accountId: string, payload: CustomerWhatsAppSend) =>
|
||||
jsonRequest<CustomerWhatsAppMessage>(`/api/v1/whatsapp/accounts/${accountId}/messages/send`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
}),
|
||||
templates: (accountId: string) =>
|
||||
jsonRequest<{ available: boolean; templates: WhatsAppTemplateRow[] }>(`/api/v1/whatsapp/accounts/${accountId}/templates`),
|
||||
logs: (accountId: string) => jsonRequest<WhatsAppAccountLogs>(`/api/v1/whatsapp/accounts/${accountId}/logs`),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue