WhatsApp Business
WhatsApp Business is a messaging platform for businesses to communicate with their customers. WhatsApp Business API is a paid service provided by Facebook.
- labels:
messaging
,chat
,sms
,whatsapp
- authentication:
bearer
Usage
ts
import { whatsappbusiness } from 'https://deno.land/x/netzo/apis/whatsappbusiness/mod.ts'
const { api } = whatsappbusiness({
businessAccountId: Deno.env.get('WHATSAPPBUSINESS_BUSINESS_ACCOUNT_ID'),
permanentToken: Deno.env.get('WHATSAPPBUSINESS_PERMANENT_TOKEN'),
})
import { whatsappbusiness } from 'https://deno.land/x/netzo/apis/whatsappbusiness/mod.ts'
const { api } = whatsappbusiness({
businessAccountId: Deno.env.get('WHATSAPPBUSINESS_BUSINESS_ACCOUNT_ID'),
permanentToken: Deno.env.get('WHATSAPPBUSINESS_PERMANENT_TOKEN'),
})
Configuration
The whatsappbusiness
factory function expects an object with the following, and returns an object with an HTTP client api
.
Param | Type | Default | Description |
---|---|---|---|
businessAccountId | string | Deno.env.get('WHATSAPPBUSINESS_BUSINESS_ACCOUNT_ID') | the account id |
permanentToken | array | Deno.env.get('WHATSAPPBUSINESS_PERMANENT_TOKEN') | the token to use for authentication |
Refer to the API documentation to get the required information.
Examples
The following examples assume you have created an api client instance. Refer to the type definitions for all exported types to pass to the api
client for typed responses.
Get business profile
Get information about your business profile.
ts
import type { Profile, QueryProfile } from 'netzo/apis/whatsappbusiness/types.ts'
const query: QueryProfile = {}
const result = await api[PHONE_NUMBER_ID].whatsapp_business_profile.get<Profile>(query)
const resultData = result.data
import type { Profile, QueryProfile } from 'netzo/apis/whatsappbusiness/types.ts'
const query: QueryProfile = {}
const result = await api[PHONE_NUMBER_ID].whatsapp_business_profile.get<Profile>(query)
const resultData = result.data
Update business profile
Update your business profile.
ts
import type { DataUpdateProfile, UpdateProfileResult } from 'netzo/apis/whatsappbusiness/types.ts'
const data: DataUpdateProfile = {
messaging_product: 'whatsapp',
about: 'About my business'
}
const resultData = await api[PHONE_NUMBER_ID].whatsapp_business_profile.post<UpdateProfileResult>(data)
import type { DataUpdateProfile, UpdateProfileResult } from 'netzo/apis/whatsappbusiness/types.ts'
const data: DataUpdateProfile = {
messaging_product: 'whatsapp',
about: 'About my business'
}
const resultData = await api[PHONE_NUMBER_ID].whatsapp_business_profile.post<UpdateProfileResult>(data)