➕ (webhook) Add Orimon in long request whitelist
This commit is contained in:
@ -27,6 +27,11 @@ import {
|
|||||||
defaultWebhookAttributes,
|
defaultWebhookAttributes,
|
||||||
} from '@typebot.io/schemas/features/blocks/integrations/webhook/constants'
|
} from '@typebot.io/schemas/features/blocks/integrations/webhook/constants'
|
||||||
import { getBlockById } from '@typebot.io/lib/getBlockById'
|
import { getBlockById } from '@typebot.io/lib/getBlockById'
|
||||||
|
import {
|
||||||
|
longReqTimeoutWhitelist,
|
||||||
|
longRequestTimeout,
|
||||||
|
responseDefaultTimeout,
|
||||||
|
} from '@typebot.io/bot-engine/blocks/integrations/webhook/executeWebhookBlock'
|
||||||
|
|
||||||
const cors = initMiddleware(Cors())
|
const cors = initMiddleware(Cors())
|
||||||
|
|
||||||
@ -156,10 +161,16 @@ export const executeWebhook =
|
|||||||
)
|
)
|
||||||
: { data: undefined, isJson: false }
|
: { data: undefined, isJson: false }
|
||||||
|
|
||||||
|
const url = parseVariables(variables)(
|
||||||
|
webhook.url + (queryParams !== '' ? `?${queryParams}` : '')
|
||||||
|
)
|
||||||
|
|
||||||
|
const isLongRequest = longReqTimeoutWhitelist.some((whiteListedUrl) =>
|
||||||
|
url?.includes(whiteListedUrl)
|
||||||
|
)
|
||||||
|
|
||||||
const request = {
|
const request = {
|
||||||
url: parseVariables(variables)(
|
url,
|
||||||
webhook.url + (queryParams !== '' ? `?${queryParams}` : '')
|
|
||||||
),
|
|
||||||
method: (webhook.method ?? defaultWebhookAttributes.method) as Method,
|
method: (webhook.method ?? defaultWebhookAttributes.method) as Method,
|
||||||
headers: headers ?? {},
|
headers: headers ?? {},
|
||||||
...basicAuth,
|
...basicAuth,
|
||||||
@ -172,6 +183,9 @@ export const executeWebhook =
|
|||||||
? body
|
? body
|
||||||
: undefined,
|
: undefined,
|
||||||
body: body && !isJson ? body : undefined,
|
body: body && !isJson ? body : undefined,
|
||||||
|
timeout: {
|
||||||
|
response: isLongRequest ? longRequestTimeout : responseDefaultTimeout,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const response = await got(request.url, omit(request, 'url'))
|
const response = await got(request.url, omit(request, 'url'))
|
||||||
|
@ -33,10 +33,11 @@ type ParsedWebhook = ExecutableWebhook & {
|
|||||||
export const responseDefaultTimeout = 10000
|
export const responseDefaultTimeout = 10000
|
||||||
export const longRequestTimeout = 120000
|
export const longRequestTimeout = 120000
|
||||||
|
|
||||||
const longReqTimeoutWhitelist = [
|
export const longReqTimeoutWhitelist = [
|
||||||
'https://api.openai.com',
|
'https://api.openai.com',
|
||||||
'https://retune.so',
|
'https://retune.so',
|
||||||
'https://www.chatbase.co',
|
'https://www.chatbase.co',
|
||||||
|
'https://channel-connector.orimon.ai',
|
||||||
]
|
]
|
||||||
|
|
||||||
export const executeWebhookBlock = async (
|
export const executeWebhookBlock = async (
|
||||||
|
Reference in New Issue
Block a user