🐛 Fix absolute URL bug with ky on backend
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
|||||||
import { convertMessageToWhatsAppMessage } from './convertMessageToWhatsAppMessage'
|
import { convertMessageToWhatsAppMessage } from './convertMessageToWhatsAppMessage'
|
||||||
import { sendWhatsAppMessage } from './sendWhatsAppMessage'
|
import { sendWhatsAppMessage } from './sendWhatsAppMessage'
|
||||||
import * as Sentry from '@sentry/nextjs'
|
import * as Sentry from '@sentry/nextjs'
|
||||||
import { HTTPError } from 'ky'
|
import { HTTPError } from 'got'
|
||||||
import { convertInputToWhatsAppMessages } from './convertInputToWhatsAppMessage'
|
import { convertInputToWhatsAppMessages } from './convertInputToWhatsAppMessage'
|
||||||
import { isNotDefined } from '@typebot.io/lib/utils'
|
import { isNotDefined } from '@typebot.io/lib/utils'
|
||||||
import { computeTypingDuration } from '../computeTypingDuration'
|
import { computeTypingDuration } from '../computeTypingDuration'
|
||||||
@@ -141,7 +141,7 @@ export const sendChatReplyToWhatsApp = async ({
|
|||||||
Sentry.captureException(err, { extra: { message } })
|
Sentry.captureException(err, { extra: { message } })
|
||||||
console.log('Failed to send message:', JSON.stringify(message, null, 2))
|
console.log('Failed to send message:', JSON.stringify(message, null, 2))
|
||||||
if (err instanceof HTTPError)
|
if (err instanceof HTTPError)
|
||||||
console.log('HTTPError', err.response.status, err.response.body)
|
console.log('HTTPError', err.response.statusCode, err.response.body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ export const sendChatReplyToWhatsApp = async ({
|
|||||||
Sentry.captureException(err, { extra: { message } })
|
Sentry.captureException(err, { extra: { message } })
|
||||||
console.log('Failed to send message:', JSON.stringify(message, null, 2))
|
console.log('Failed to send message:', JSON.stringify(message, null, 2))
|
||||||
if (err instanceof HTTPError)
|
if (err instanceof HTTPError)
|
||||||
console.log('HTTPError', err.response.status, err.response.body)
|
console.log('HTTPError', err.response.statusCode, err.response.body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,7 +253,7 @@ const executeClientSideAction =
|
|||||||
Sentry.captureException(err, { extra: { message } })
|
Sentry.captureException(err, { extra: { message } })
|
||||||
console.log('Failed to send message:', JSON.stringify(message, null, 2))
|
console.log('Failed to send message:', JSON.stringify(message, null, 2))
|
||||||
if (err instanceof HTTPError)
|
if (err instanceof HTTPError)
|
||||||
console.log('HTTPError', err.response.status, err.response.body)
|
console.log('HTTPError', err.response.statusCode, err.response.body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import ky from 'ky'
|
|
||||||
import {
|
import {
|
||||||
WhatsAppCredentials,
|
WhatsAppCredentials,
|
||||||
WhatsAppSendingMessage,
|
WhatsAppSendingMessage,
|
||||||
} from '@typebot.io/schemas/features/whatsapp'
|
} from '@typebot.io/schemas/features/whatsapp'
|
||||||
import { env } from '@typebot.io/env'
|
import { env } from '@typebot.io/env'
|
||||||
|
import got from 'got'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
to: string
|
to: string
|
||||||
@@ -16,7 +16,7 @@ export const sendWhatsAppMessage = async ({
|
|||||||
message,
|
message,
|
||||||
credentials,
|
credentials,
|
||||||
}: Props) =>
|
}: Props) =>
|
||||||
ky.post(
|
got.post(
|
||||||
`${env.WHATSAPP_CLOUD_API_URL}/v17.0/${credentials.phoneNumberId}/messages`,
|
`${env.WHATSAPP_CLOUD_API_URL}/v17.0/${credentials.phoneNumberId}/messages`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user