2
0

📝 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:
Clairton Rodrigo Heinzen
2024-01-25 07:53:57 -03:00
committed by Baptiste Arnaud
parent ef05b71869
commit 47af9a9a59
6 changed files with 20 additions and 10 deletions

View File

@ -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}`,
},