🧑💻 (whatsapp) Improve whatsapp start log
This commit is contained in:
@@ -75,10 +75,10 @@ export const resumeWhatsAppFlow = async ({
|
|||||||
credentials: { ...credentials, id: credentialsId as string },
|
credentials: { ...credentials, id: credentialsId as string },
|
||||||
contact,
|
contact,
|
||||||
})
|
})
|
||||||
: undefined
|
: { error: 'workspaceId not found' }
|
||||||
|
|
||||||
if (!resumeResponse) {
|
if ('error' in resumeResponse) {
|
||||||
console.error('Could not find or create session', sessionId)
|
console.log('Chat not starting:', resumeResponse.error)
|
||||||
return {
|
return {
|
||||||
message: 'Message received',
|
message: 'Message received',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const startWhatsAppSession = async ({
|
|||||||
| (ChatReply & {
|
| (ChatReply & {
|
||||||
newSessionState: SessionState
|
newSessionState: SessionState
|
||||||
})
|
})
|
||||||
| undefined
|
| { error: string }
|
||||||
> => {
|
> => {
|
||||||
const publicTypebotsWithWhatsAppEnabled =
|
const publicTypebotsWithWhatsAppEnabled =
|
||||||
(await prisma.publicTypebot.findMany({
|
(await prisma.publicTypebot.findMany({
|
||||||
@@ -72,7 +72,10 @@ export const startWhatsAppSession = async ({
|
|||||||
(publicTypebot) => !publicTypebot.settings.whatsApp?.startCondition
|
(publicTypebot) => !publicTypebot.settings.whatsApp?.startCondition
|
||||||
)
|
)
|
||||||
|
|
||||||
if (isNotDefined(publicTypebot)) return
|
if (isNotDefined(publicTypebot))
|
||||||
|
return botsWithWhatsAppEnabled.length > 0
|
||||||
|
? { error: 'Message did not matched any condition' }
|
||||||
|
: { error: 'No public typebot with WhatsApp integration found' }
|
||||||
|
|
||||||
const sessionExpiryTimeoutHours =
|
const sessionExpiryTimeoutHours =
|
||||||
publicTypebot.settings.whatsApp?.sessionExpiryTimeout ??
|
publicTypebot.settings.whatsApp?.sessionExpiryTimeout ??
|
||||||
|
|||||||
Reference in New Issue
Block a user