Sends an SMS text message with Twilio.



To send or receive messages via the Twilio API for WhatsApp, prepend the to or from numbers with whatsapp:.

to: "whatsapp:+15558675309",
from: "whatsapp:+15551234567",


exports = function() {
    const twilio ="myTwilio");
        to: "+15558675309",
        from: "+15551234567",
        body: "Hello from Realm!"


Parameter Type Description
args document

A document of the following form:

    "to": <string>,   // recipient phone #
    "from": <string>, // sender phone #
    "body": <string>  // message
} string The recipient’s phone number in E.164 Format.
args.from string A phone number associated with your Twilio account in E.164 Format.
args.body string The message to send.

Return Value

The twilio.send() action does not return a value.

Rule Templates

Users Can Send Only Messages from a Specific Phone Number

  "%%args.from": "+15551234"

Users Can Only Send Messages to a Limited Set of Phone Numbers

  "": {
    "$in": [

Users Can Only Send Messages to Themselves

  "%%true": {
    "%function": {
      "name": "isCurrentUsersPhoneNumber",
      "arguments": [


This template calls an example function named isCurrentUsersPhoneNumber that does the following:

  1. Accepts the phone number provided in the to argument
  2. Queries MongoDB for a user document that matches the current user’s id
  3. Compares the provided phone number to the number listed in the user document
  4. Returns the boolean result of the comparison
exports = function(toPhone) {
  const mdb ='mongodb-atlas');
  const users = mdb.db('demo').collection('users');
  const user = users.findOne({ _id: });
  return user.phoneNumber === toPhone;