Iḿ using N8N and chatwoot.
I receive a base64 encoded pdf file in N8N and must return to the chatwoot this pdf file to specific user (user who asked for the file).
How can I do that in N8N? I tried chatwoot node but it is not working…
Iḿ using N8N and chatwoot.
I receive a base64 encoded pdf file in N8N and must return to the chatwoot this pdf file to specific user (user who asked for the file).
How can I do that in N8N? I tried chatwoot node but it is not working…
Hello @PapIro_SIlva.
Hope you are well!
The default N8N Chatwoot node is usually focused on more common operations like creating contacts, conversations or sending text messages. Sending attachments, especially when you need to build the file from Base64 data, often exceeds the simplified functionality of the node and requires the flexibility of HTTP Request to assemble the multipart/form-data call correctly, as expected by the Chatwoot API.
Test this flow below and see if it works! Remember to adjust the field names (pdfBase64, account_id, conversation_id, filename) according to the actual data coming to your nodes.
Convert Base64 to Binary:
Add a Move Binary Data node.
Select Base64 to Binary.
Use an expression to point to the field that contains your Base64 string (e.g. {{ $json.pdfBase64 }}).
Set a name for the resulting binary data, e.g. data.
Expand the Add Option and select File Name.
Set a name for the PDF file that will be sent to Chatwoot (e.g. {{ $json.filename || ‘requested_document.pdf’ }}). This is crucial so that Chatwoot knows the name of the attachment.
Add an HTTP Request node.
Method: POST
Construct the Chatwoot API URL to send messages. Use expressions to insert the necessary IDs:
https://<YOUR_CHATWOOT_URL>/api/v1/accounts/{{ $json.account_id }}/conversations/{{ $json.conversation_id }}/messages
Replace <YOUR_CHATWOOT_URL> with your actual Chatwoot URL. Make sure that $json.account_id and $json.conversation_id point to the correct fields in your flow.
Select Header Auth.
api_access_token
Paste your Chatwoot API Token here (or use N8N credentials).
In Body Content select Form-Data Multipart.
Configure the Body Parameters:
Click Add Body Parameter.
Name: content
Value: (Optional) Enter the text message that will accompany the file (e.g. Here is the PDF you requested.).
Click Add Body Parameter.
Name: message_type
Value: outgoing (to indicate that this is a message sent by your automation/bot).
Click Add Body Parameter.
Name: private
Value: false (to make the message visible to the contact).
Click Add Body Parameter.
Name: attachments (The square brackets are important!)
Value: Leave this field empty.
Node Options (Important for Attachment):
Check the Send Binary Data? option. as Yes.
Input Data Field Name: Enter the name you defined as Destination Key in the Move Binary Data node (in this example, it was data).
I hope this helps.
Best regards
@Papiro_Silva If this suggestion solved your problem, please mark my post as the solution (blue box with check mark) so that this ongoing discussion does not distract others who want to find the answer to the original question. Thanks
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.