0

Send SMS

by
Published Jun 6, 2022

Send a simple text-only SMS. [See the docs](https://www.twilio.com/docs/sms/api/message-resource#create-a-message-resource) for more information

Script twilio Verified

The script

Submitted by hugo697 Bun
Verified 398 days ago
1
import { Twilio } from "twilio";
2

3
type Twilio = {
4
  accountSid: string;
5
  token: string;
6
};
7

8
export async function main(
9
  twilio: Twilio,
10
  body: string,
11
  to: string,
12
  from: string
13
) {
14
  const client = new Twilio(twilio.accountSid, twilio.token);
15
  const message = await client.messages.create({
16
    body: body,
17
    to: to,
18
    from: from,
19
  });
20
  return message;
21
}
22

Other submissions
  • Submitted by hugo697 Deno
    Created 974 days ago
    1
    import { Twilio } from "twilio";
    2
    
    
    3
    type Twilio = {
    4
      accountSid: string;
    5
      token: string;
    6
    };
    7
    
    
    8
    export async function main(
    9
      twilio: Twilio,
    10
      body: string,
    11
      to: string,
    12
      from: string
    13
    ): Promise<void> {
    14
      const client = new Twilio(twilio.accountSid, twilio.token);
    15
      const message = await client.messages.create({
    16
        body: body,
    17
        to: to,
    18
        from: from,
    19
      });
    20
      console.log(message.sid);
    21
    }
    22