Skip to content

Send WhatsApp File

Type: mosend-send-file  ·  Package: Mosend WhatsApp Activities v1.0.4  ·  Output: object

Sends a file from the robot’s disk (a PDF invoice, a photo, a receipt, an audio clip) over WhatsApp, with optional accompanying text. The robot uploads the file to Mosend and then sends it to the recipient.

  1. Checks that the filePath file exists and infers its type from the extension:

    TypeExtensionsWhatsApp limit
    Image.jpg, .jpeg, .png, .webp, .gif5 MB
    Video.mp4, .3gp16 MB
    Audio.mp3, .ogg, .aac16 MB
    Document.pdf, .doc(x), .xls(x), .ppt(x), .txt, .csv and any other extension100 MB
  2. If the file exceeds the limit for its type, it fails before uploading it.

  3. Gets the Mosend session, identifies the from number and uploads the file to Mosend.

  4. Sends the message to to with the file, the caption (caption) and, for documents, the name the recipient will see (fileName).

ParameterTypeDefaultDescription
integrationstring—Name of the Mosend account in the environment’s Centro › Recursos › Integraciones (Center › Resources › Integrations), Mensajería section. E.g.: mosend.
fromstring—WhatsApp number of the sending account, as shown in Mosend (e.g. +57 300 000 0000), or its Mosend id.
tostring—Recipient phone in international format, with or without +. E.g.: +57 300 000 0001.
filePathstring—Full path of the file on this machine. The type (image, document, video, audio) is inferred from the extension. E.g.: C:\invoices\F-0001.pdf.
ParameterTypeDefaultDescription
captionstring—Text shown with the file.
fileNamestringfile nameName the recipient sees for documents. Defaults to the file’s name.

Returns an object with:

FieldDescription
idMessage id in Mosend.
statusStatus reported by Mosend (defaults to sent).
toRecipient number, digits only.
conversationIdConversation id in Mosend.
mediaIdId of the file uploaded to Mosend.

The activity fails with these messages, without a prefix; catch them with Try / Catch:

MessageCause and fix
'…' is required.A required parameter is missing (the message names it).
The Mosend integration '…' does not exist in this environment. Create it in Center › Resources › Integrations.The integration name doesn’t match any Mosend integration in the environment where the robot runs. Check it under Integrations in Zoan Cloud.
Mosend activities need the Zoan Cloud runtime context (…).The process isn’t running from Zoan Cloud or from the Designer signed in.
Local file not found.filePath doesn’t exist on the robot’s machine.
'to' must be a phone number in international format (e.g. +57 300 123 4567).to has fewer than 8 digits.
The 'from' WhatsApp number was not found in the Mosend organization. …from doesn’t match any number in the account. Use the number as shown in Mosend or its id.
The file exceeds WhatsApp's limit for …s (… MB).The file is larger than its type’s limit. Share it with a link (for example with Get Storage File URL).
Mosend did not return a media id after the upload.The upload to Mosend didn’t return the file. Retry.
Zoan Cloud refused the Mosend session for '…': HTTP …: …Zoan Cloud couldn’t hand out the integration’s session (for example, the OAuth authorization expired or was revoked). Reconnect the integration.
Mosend rejected the session (401). Reconnect the integration in Center › Resources › Integrations.The API key or token is no longer valid. Reconnect the integration.
Mosend denied the operation (403): the account lacks the permission. …The Mosend account doesn’t have permission for that operation.
Mosend rate limit reached (429). Retry later.Too many requests in a row. Retry with Retry and a wait.
Mosend responded HTTP …: …Another Mosend error; the detail (up to 300 characters of the response) follows the colon.
Send WhatsApp File integration = "mosend" from = "+57 300 000 0000"
to = "+57 300 000 0001"
filePath = "C:/invoices/F-0001.pdf"
fileName = "Invoice F-0001.pdf"
caption = "Hi, Test Customer. Your invoice is attached."
→ output: delivery