Skip to content

Send WhatsApp Text

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

Sends a WhatsApp text message from one of the numbers of your Mosend account. It is the way to reply to a customer who has just written: confirm a request, give a status update, ask for a piece of information. Returns the id and status of the sent message.

  1. Gets the Mosend session of the integration set in integration (see how the robot connects).
  2. Identifies the sender number from: it accepts the number as shown in Mosend or its id.
  3. Cleans the recipient number to (only the digits are kept) and sends the text.

The text supports WhatsApp formatting (*bold*, _italic_). If it exceeds 4096 characters (WhatsApp’s limit), it is cut to that length before sending and a warning in the log states how many characters it had and how many were sent. To send a long text in full, split it into several messages.

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.
textstring—Message text. Supports *bold* and _italic_. Max 4096 characters; a longer text is truncated, with a warning in the log.
ParameterTypeDefaultDescription
replyToMessageIdstring—Id of a previous message to quote in the reply.

Returns an object with:

FieldDescription
idMessage id in Mosend.
statusStatus reported by Mosend (defaults to sent).
toRecipient number, digits only (e.g. 573000000001).
conversationIdConversation id in 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.
'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.
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 Text integration = "mosend" from = "+57 300 000 0000"
to = "+57 300 000 0001"
text = "Hi, Test Customer. We received your request *#0001* and are reviewing it."
→ output: message
Log level = info message = "Message sent: " + str(message["id"])