T
Typebot9mo ago
LaRocca

Whatsapp Audio

Hey guys, how can I use the file block to upload a whatsapp audio? What I am trying to achieve here is this: The user sent an audio using whatsapp (I am using the official whatsapp integration in typebot) I upload this audio to N8N using a webhook. In N8N I am making the transcription of the audio. I already tested and everything is working, but now I need to find a way to differentiate the text that user sent from audio. How can I do that?
7 Replies
LaRocca
LaRoccaOP9mo ago
no one?
Azeem
Azeem9mo ago
To differentiate between audio transcriptions and regular text in your Typebot flow: When receiving an audio file Use a File block in Typebot to get the WhatsApp audio. Send it to N8N for transcription. When N8N sends the transcription back, add a prefix like "[Audio]" to the text. For regular text messages Process them as you normally would, without any special prefix. In your Typebot flow Check if the incoming message starts with "[Audio]". If it does, you know it's a transcription from audio. If it doesn't, it's regular text input from the user.
LaRocca
LaRoccaOP9mo ago
Cool man, it could work, Thank you very much. Will try that. Hey @Azeem, I am trying to do what you suggested, but how can I know if the message sent is a audio? I can't use the file block if the user sent a text message, otherwise I will have an error. I need to understand, somehow that the message sent is an audio. @Baptiste any chance to have the type of message from whatsapp as a environment variable? I know that they sent a type field saying it is a media or text in the json. Maybe we can add this to the environment, so I can test it on typebot.
Baptiste
Baptiste9mo ago
Why don't you send a HTTP request to the URL and get the Content-Type header from the response? It should provide the file type Because Typebot does not natively know the file type either from WhatsApp uploads
LaRocca
LaRoccaOP9mo ago
I am still need to know if what I am receaving is a URL or a simple Text, otherwise I will have an error on the HTTP Request. Am I correct?
Baptiste
Baptiste9mo ago
Right, you should use the Allow attachments option in the Text input then It differentiates the Uploaded file variable from the text one
LaRocca
LaRoccaOP9mo ago
@Baptiste it worked. Thank you very much. I just set the attachment option and tested if the variable is set. Thanks for your support

Did you find this page helpful?