@@ -32,7 +32,6 @@ export const getResultExample = authenticatedProcedure
|
||||
})
|
||||
)
|
||||
.query(async ({ input: { typebotId, blockId }, ctx: { user } }) => {
|
||||
console.log('user', user)
|
||||
const typebot = (await prisma.typebot.findFirst({
|
||||
where: canReadTypebots(typebotId, user),
|
||||
select: {
|
||||
|
||||
@@ -17,7 +17,7 @@ export const convertVariablesForTestToVariables = (
|
||||
) as Variable
|
||||
return { ...variable, value: parseVariableValue(variableForTest.value) }
|
||||
}, {}),
|
||||
]
|
||||
].filter((v) => v.value)
|
||||
}
|
||||
|
||||
const parseVariableValue = (value: string | undefined): string | string[] => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Variable, HttpResponse } from '@typebot.io/schemas'
|
||||
import { sendRequest } from '@typebot.io/lib'
|
||||
import { env } from '@typebot.io/env'
|
||||
|
||||
export const executeWebhook = (
|
||||
typebotId: string,
|
||||
@@ -8,7 +7,7 @@ export const executeWebhook = (
|
||||
{ blockId }: { blockId: string }
|
||||
) =>
|
||||
sendRequest<HttpResponse>({
|
||||
url: `${env.NEXT_PUBLIC_VIEWER_URL[0]}/api/typebots/${typebotId}/blocks/${blockId}/executeWebhook`,
|
||||
url: `/api/typebots/${typebotId}/blocks/${blockId}/testWebhook`,
|
||||
method: 'POST',
|
||||
body: {
|
||||
variables,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { z } from 'zod'
|
||||
import { isReadWorkspaceFobidden } from '@/features/workspace/helpers/isReadWorkspaceFobidden'
|
||||
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
|
||||
import { ZemanticAiCredentials } from '@typebot.io/schemas/features/blocks/integrations/zemanticAi'
|
||||
import got from 'got'
|
||||
import ky from 'ky'
|
||||
|
||||
export const listProjects = authenticatedProcedure
|
||||
.input(
|
||||
@@ -58,7 +58,7 @@ export const listProjects = authenticatedProcedure
|
||||
const url = 'https://api.zemantic.ai/v1/projects'
|
||||
|
||||
try {
|
||||
const response = await got
|
||||
const response = await ky
|
||||
.get(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${data.apiKey}`,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
import { customDomainSchema } from '@typebot.io/schemas/features/customDomains'
|
||||
import got, { HTTPError } from 'got'
|
||||
import ky, { HTTPError } from 'ky'
|
||||
import { env } from '@typebot.io/env'
|
||||
import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden'
|
||||
import { trackEvents } from '@typebot.io/telemetry/trackEvents'
|
||||
@@ -61,12 +61,12 @@ export const createCustomDomain = authenticatedProcedure
|
||||
try {
|
||||
await createDomainOnVercel(name)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
if (err instanceof HTTPError && err.response.statusCode !== 409)
|
||||
if (err instanceof HTTPError && err.response.status !== 409) {
|
||||
throw new TRPCError({
|
||||
code: 'INTERNAL_SERVER_ERROR',
|
||||
message: 'Failed to create custom domain on Vercel',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const customDomain = await prisma.customDomain.create({
|
||||
@@ -91,8 +91,12 @@ export const createCustomDomain = authenticatedProcedure
|
||||
})
|
||||
|
||||
const createDomainOnVercel = (name: string) =>
|
||||
got.post({
|
||||
url: `https://api.vercel.com/v10/projects/${env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains?teamId=${env.VERCEL_TEAM_ID}`,
|
||||
headers: { Authorization: `Bearer ${env.VERCEL_TOKEN}` },
|
||||
json: { name },
|
||||
})
|
||||
ky.post(
|
||||
`https://api.vercel.com/v10/projects/${env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains?teamId=${env.VERCEL_TEAM_ID}`,
|
||||
{
|
||||
headers: {
|
||||
authorization: `Bearer ${env.VERCEL_TOKEN}`,
|
||||
},
|
||||
json: { name },
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ import prisma from '@typebot.io/lib/prisma'
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { z } from 'zod'
|
||||
import got from 'got'
|
||||
import ky from 'ky'
|
||||
import { env } from '@typebot.io/env'
|
||||
import { isWriteWorkspaceForbidden } from '@/features/workspace/helpers/isWriteWorkspaceForbidden'
|
||||
|
||||
@@ -63,7 +63,9 @@ export const deleteCustomDomain = authenticatedProcedure
|
||||
})
|
||||
|
||||
const deleteDomainOnVercel = (name: string) =>
|
||||
got.delete({
|
||||
url: `https://api.vercel.com/v9/projects/${env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains/${name}?teamId=${env.VERCEL_TEAM_ID}`,
|
||||
headers: { Authorization: `Bearer ${env.VERCEL_TOKEN}` },
|
||||
})
|
||||
ky.delete(
|
||||
`https://api.vercel.com/v9/projects/${env.NEXT_PUBLIC_VERCEL_VIEWER_PROJECT_NAME}/domains/${name}?teamId=${env.VERCEL_TEAM_ID}`,
|
||||
{
|
||||
headers: { Authorization: `Bearer ${env.VERCEL_TOKEN}` },
|
||||
}
|
||||
)
|
||||
|
||||
@@ -377,6 +377,7 @@ const SystemUserToken = ({
|
||||
<ListItem>Copy and paste the generated token:</ListItem>
|
||||
<TextInput
|
||||
isRequired
|
||||
type="password"
|
||||
label="System User Token"
|
||||
defaultValue={initialToken}
|
||||
onChange={(val) => setToken(val.trim())}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { z } from 'zod'
|
||||
import got from 'got'
|
||||
import ky from 'ky'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { decrypt } from '@typebot.io/lib/api/encryption/decrypt'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
@@ -22,16 +22,13 @@ export const getPhoneNumber = authenticatedProcedure
|
||||
code: 'NOT_FOUND',
|
||||
message: 'Credentials not found',
|
||||
})
|
||||
const { display_phone_number } = (await got(
|
||||
`${env.WHATSAPP_CLOUD_API_URL}/v17.0/${credentials.phoneNumberId}`,
|
||||
{
|
||||
const { display_phone_number } = await ky
|
||||
.get(`${env.WHATSAPP_CLOUD_API_URL}/v17.0/${credentials.phoneNumberId}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${credentials.systemUserAccessToken}`,
|
||||
},
|
||||
}
|
||||
).json()) as {
|
||||
display_phone_number: string
|
||||
}
|
||||
})
|
||||
.json<{ display_phone_number: string }>()
|
||||
|
||||
const formattedPhoneNumber = `${
|
||||
display_phone_number.startsWith('+') ? '' : '+'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { authenticatedProcedure } from '@/helpers/server/trpc'
|
||||
import { z } from 'zod'
|
||||
import got from 'got'
|
||||
import ky from 'ky'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { WhatsAppCredentials } from '@typebot.io/schemas/features/whatsapp'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
@@ -28,21 +28,23 @@ export const getSystemTokenInfo = authenticatedProcedure
|
||||
})
|
||||
const {
|
||||
data: { expires_at, scopes, app_id, application },
|
||||
} = (await got(
|
||||
`${env.WHATSAPP_CLOUD_API_URL}/v17.0/debug_token?input_token=${credentials.systemUserAccessToken}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${credentials.systemUserAccessToken}`,
|
||||
},
|
||||
}
|
||||
).json()) as {
|
||||
data: {
|
||||
app_id: string
|
||||
application: string
|
||||
expires_at: number
|
||||
scopes: string[]
|
||||
}
|
||||
}
|
||||
} = await ky
|
||||
.get(
|
||||
`${env.WHATSAPP_CLOUD_API_URL}/v17.0/debug_token?input_token=${credentials.systemUserAccessToken}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${credentials.systemUserAccessToken}`,
|
||||
},
|
||||
}
|
||||
)
|
||||
.json<{
|
||||
data: {
|
||||
app_id: string
|
||||
application: string
|
||||
expires_at: number
|
||||
scopes: string[]
|
||||
}
|
||||
}>()
|
||||
|
||||
return {
|
||||
appId: app_id,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { z } from 'zod'
|
||||
import { TRPCError } from '@trpc/server'
|
||||
import { startSession } from '@typebot.io/bot-engine/startSession'
|
||||
import { env } from '@typebot.io/env'
|
||||
import { HTTPError } from 'got'
|
||||
import { HTTPError } from 'ky'
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { saveStateToDatabase } from '@typebot.io/bot-engine/saveStateToDatabase'
|
||||
import { restartSession } from '@typebot.io/bot-engine/queries/restartSession'
|
||||
@@ -169,7 +169,7 @@ export const startWhatsAppPreview = authenticatedProcedure
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
if (err instanceof HTTPError) console.log(err.response.body)
|
||||
if (err instanceof HTTPError) console.log(await err.response.text())
|
||||
throw new TRPCError({
|
||||
code: 'INTERNAL_SERVER_ERROR',
|
||||
message: 'Request to Meta to send preview message failed',
|
||||
|
||||
Reference in New Issue
Block a user