Docs Menu

twilio.send()

On this page

  • Definition
  • Usage
  • Example
  • Parameters
  • Return Value
  • Rule Templates
  • Users Can Send Only Messages from a Specific Phone Number
  • Users Can Only Send Messages to a Limited Set of Phone Numbers
  • Users Can Only Send Messages to Themselves
twilio.send()

Sends an SMS text message with Twilio.

Note

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",

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

{
"%%args.from": "+15551234"
}
{
"%%args.to": {
"$in": [
"+15551234",
"+18675309"
]
}
}
{
"%%true": {
"%function": {
"name": "isCurrentUsersPhoneNumber",
"arguments": [
"%%args.to"
]
}
}
}
Note

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 = context.services.get('mongodb-atlas');
const users = mdb.db('demo').collection('users');
const user = users.findOne({ _id: context.user.id });
return user.phoneNumber === toPhone;
}
Give Feedback
MongoDB logo
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.