Skip to content

Commit

Permalink
🚑 (fileUpload) Fix web bot file upload input skip option
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Sep 2, 2023
1 parent 60abddd commit 968c5e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
23 changes: 18 additions & 5 deletions apps/viewer/src/features/chat/helpers/continueBotFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,16 @@ export const continueBotFlow =
let formattedReply: string | undefined

if (isInputBlock(block)) {
const parseResult = parseReply(newSessionState)(reply, block)
const parsedReplyResult = parseReply(newSessionState)(reply, block)

if (parseResult.status === 'fail')
if (parsedReplyResult.status === 'fail')
return {
...(await parseRetryMessage(newSessionState)(block)),
newSessionState,
}

formattedReply = 'reply' in parseResult ? parseResult.reply : undefined
formattedReply =
'reply' in parsedReplyResult ? parsedReplyResult.reply : undefined
const nextEdgeId = getOutgoingEdgeId(newSessionState)(
block,
formattedReply
Expand Down Expand Up @@ -310,14 +311,15 @@ const getOutgoingEdgeId =
const parseReply =
(state: SessionState) =>
(inputValue: string | undefined, block: InputBlock): ParsedReply => {
if (!inputValue) return { status: 'fail' }
switch (block.type) {
case InputBlockType.EMAIL: {
if (!inputValue) return { status: 'fail' }
const isValid = validateEmail(inputValue)
if (!isValid) return { status: 'fail' }
return { status: 'success', reply: inputValue }
}
case InputBlockType.PHONE: {
if (!inputValue) return { status: 'fail' }
const formattedPhone = formatPhoneNumber(
inputValue,
block.options.defaultCountryCode
Expand All @@ -326,38 +328,49 @@ const parseReply =
return { status: 'success', reply: formattedPhone }
}
case InputBlockType.URL: {
if (!inputValue) return { status: 'fail' }
const isValid = validateUrl(inputValue)
if (!isValid) return { status: 'fail' }
return { status: 'success', reply: inputValue }
}
case InputBlockType.CHOICE: {
if (!inputValue) return { status: 'fail' }
return parseButtonsReply(state)(inputValue, block)
}
case InputBlockType.NUMBER: {
if (!inputValue) return { status: 'fail' }
const isValid = validateNumber(inputValue)
if (!isValid) return { status: 'fail' }
return { status: 'success', reply: inputValue }
}
case InputBlockType.DATE: {
if (!inputValue) return { status: 'fail' }
return parseDateReply(inputValue, block)
}
case InputBlockType.FILE: {
if (!inputValue) return { status: 'skip' }
if (!inputValue)
return block.options.isRequired
? { status: 'fail' }
: { status: 'skip' }
return { status: 'success', reply: inputValue }
}
case InputBlockType.PAYMENT: {
if (!inputValue) return { status: 'fail' }
if (inputValue === 'fail') return { status: 'fail' }
return { status: 'success', reply: inputValue }
}
case InputBlockType.RATING: {
if (!inputValue) return { status: 'fail' }
const isValid = validateRatingReply(inputValue, block)
if (!isValid) return { status: 'fail' }
return { status: 'success', reply: inputValue }
}
case InputBlockType.PICTURE_CHOICE: {
if (!inputValue) return { status: 'fail' }
return parsePictureChoicesReply(state)(inputValue, block)
}
case InputBlockType.TEXT: {
if (!inputValue) return { status: 'fail' }
return { status: 'success', reply: inputValue }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const getIncomingMessageContent = async ({
message: WhatsAppIncomingMessage
systemUserToken: string | undefined
downloadPath?: string
}): Promise<string> => {
}): Promise<string | undefined> => {
switch (message.type) {
case 'text':
return message.text.body
Expand All @@ -144,7 +144,7 @@ const getIncomingMessageContent = async ({
}
case 'document':
case 'audio':
return ''
return
case 'video':
case 'image':
if (!systemUserToken || !downloadPath) return ''
Expand Down

4 comments on commit 968c5e3

@vercel
Copy link

@vercel vercel bot commented on 968c5e3 Sep 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 968c5e3 Sep 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 968c5e3 Sep 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 968c5e3 Sep 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

kopibayane.com
panther.cr7.ai
panther.cr8.ai
pay.sifuim.com
penguin.cr8.ai
segredomeu.com
test.bot.gives
digitando.online
faqs.nigerias.io
feiraodehoje.com
georgemarttt.com
go.chatbotcv.com
haymanevents.com
kw.wpwakanda.com
localamor.online
lojamundobox.com
myrentalhost.com
silvercop.com.br
silvercop.online
stan.vselise.com
typebot.aloe.bot
vidalimentar.com
voicehelp.cr8.ai
web.bjogador.com
www.pantaflow.ai
zap.fundviser.in
analistamines.com
app.bouclidom.com
app.chatforms.net
appbotcontato.com
appmillion.online
bot.cerograsa.com
bot.chatbotcv.com
bot.hostnation.de
bot.ketoolife.com
bot.maitempah.com
bot.phuonghub.com
bot.reviewamp.com
bot.reviewzer.com
bot.uluhub.com.br
cares.urlabout.me
chat.ezbooking.ai
chat.gaswadern.de
chat.gniorder.com
chat.onrentme.com
chat.rojie.online
chatdocidadao.com
chatwebonline.com
fmm.wpwakanda.com
footballmeetup.ie
gentleman-shop.fr
island.wakanda.is
k1.kandabrand.com
kp.pedroknoll.com
lb.ticketfute.com
metodoelev.com.br
nutriandreia.shop
viewer-v2-typebot-io.vercel.app
mdb.assessoria.marinho.progenbr.com
mdb.assessoria.rodrigo.progenbr.com
register.thailandmicespecialist.com
mdb.assessoria.desideri.progenbr.com
mdb.assessoria.fernanda.progenbr.com
mdb.assessoria.jbatista.progenbr.com
mdb.assessoria.mauricio.progenbr.com
mdb.evento.autocadastro.progenbr.com
form.shopmercedesbenzsouthorlando.com
mdb.evento.equipeinterna.progenbr.com
bot.studiotecnicoimmobiliaremerelli.it
mdb.assessoria.boaventura.progenbr.com
mdb.assessoria.jtrebesqui.progenbr.com
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
gabinete.baleia.formulario.progenbr.com
mdb.assessoria.carreirinha.progenbr.com
chrome-os-inquiry-system.itschromeos.com
mdb.assessoria.paulomarques.progenbr.com
viewer-v2-git-main-typebot-io.vercel.app
main-menu-for-itschromeos.itschromeos.com
mdb.assessoria.qrcode.ademir.progenbr.com
mdb.assessoria.qrcode.arthur.progenbr.com
mdb.assessoria.qrcode.danilo.progenbr.com
mdb.assessoria.qrcode.marcao.progenbr.com
mdb.assessoria.qrcode.marcio.progenbr.com
mdb.assessoria.qrcode.aloisio.progenbr.com
mdb.assessoria.qrcode.girotto.progenbr.com
mdb.assessoria.qrcode.marinho.progenbr.com
mdb.assessoria.qrcode.rodrigo.progenbr.com
mdb.assessoria.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.desideri.progenbr.com
mdb.assessoria.qrcode.fernanda.progenbr.com
mdb.assessoria.qrcode.jbatista.progenbr.com
mdb.assessoria.qrcode.mauricio.progenbr.com
mdb.assessoria.fernanda.regional.progenbr.com
mdb.assessoria.qrcode.boaventura.progenbr.com
mdb.assessoria.qrcode.jtrebesqui.progenbr.com
mdb.assessoria.qrcode.carreirinha.progenbr.com
mdb.assessoria.qrcode.paulomarques.progenbr.com
mdb.assessoria.qrcode.carlosalexandre.progenbr.com
mdb.assessoria.qrcode.fernanda.regional.progenbr.com

Please sign in to comment.