📝 Add env WHATSAPP_CLOUD_API_URL to possible change https://gr… (#1170)
refs #1117 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Dynamically construct API URLs for WhatsApp features using environment variables for improved reliability and configurability. - Updated `sendWhatsAppMessage` function to use `env.WHATSAPP_CLOUD_API_URL` for URL construction, allowing for more dynamic configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Baptiste Arnaud <baptiste.arnaud95@gmail.com>
This commit is contained in:
committed by
Baptiste Arnaud
parent
ef05b71869
commit
47af9a9a59
@ -3,6 +3,7 @@ import {
|
||||
WhatsAppCredentials,
|
||||
WhatsAppSendingMessage,
|
||||
} from '@typebot.io/schemas/features/whatsapp'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
type Props = {
|
||||
to: string
|
||||
@ -16,7 +17,7 @@ export const sendWhatsAppMessage = async ({
|
||||
credentials,
|
||||
}: Props) =>
|
||||
got.post({
|
||||
url: `https://graph.facebook.com/v17.0/${credentials.phoneNumberId}/messages`,
|
||||
url: `${env.WHATSAPP_CLOUD_API_URL}/v17.0/${credentials.phoneNumberId}/messages`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${credentials.systemUserAccessToken}`,
|
||||
},
|
||||
|
5
packages/env/env.ts
vendored
5
packages/env/env.ts
vendored
@ -283,6 +283,11 @@ const whatsAppEnv = {
|
||||
WHATSAPP_PREVIEW_FROM_PHONE_NUMBER_ID: z.string().min(1).optional(),
|
||||
WHATSAPP_PREVIEW_TEMPLATE_NAME: z.string().min(1).optional(),
|
||||
WHATSAPP_PREVIEW_TEMPLATE_LANG: z.string().min(1).optional().default('en'),
|
||||
WHATSAPP_CLOUD_API_URL: z
|
||||
.string()
|
||||
.url()
|
||||
.optional()
|
||||
.default('https://graph.facebook.com'),
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user