Skip to content

Commit

Permalink
🧑‍💻 (whatsapp) Improve whatsapp start log
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Oct 25, 2023
1 parent 1ff5881 commit c2a08c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export const resumeWhatsAppFlow = async ({
credentials: { ...credentials, id: credentialsId as string },
contact,
})
: undefined
: { error: 'workspaceId not found' }

if (!resumeResponse) {
console.error('Could not find or create session', sessionId)
if ('error' in resumeResponse) {
console.log('Chat not starting:', resumeResponse.error)
return {
message: 'Message received',
}
Expand Down
7 changes: 5 additions & 2 deletions packages/bot-engine/whatsapp/startWhatsAppSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const startWhatsAppSession = async ({
| (ChatReply & {
newSessionState: SessionState
})
| undefined
| { error: string }
> => {
const publicTypebotsWithWhatsAppEnabled =
(await prisma.publicTypebot.findMany({
Expand Down Expand Up @@ -72,7 +72,10 @@ export const startWhatsAppSession = async ({
(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 =
publicTypebot.settings.whatsApp?.sessionExpiryTimeout ??
Expand Down

0 comments on commit c2a08c4

Please sign in to comment.