0

Send MMS

by
Published Jun 6, 2022

Send an SMS with text and media files. [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
  mediaUrl: string[],
12
  from: string,
13
  to: string
14
) {
15
  const client = new Twilio(twilio.accountSid, twilio.token);
16
  const message = await client.messages.create({
17
    body: body,
18
    mediaUrl: mediaUrl,
19
    from: from,
20
    to: to,
21
  });
22
  return message;
23
}
24

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
      mediaUrl: string[],
    12
      from: string,
    13
      to: string
    14
    ): Promise<void> {
    15
      const client = new Twilio(twilio.accountSid, twilio.token);
    16
      const message = await client.messages.create({
    17
        body: body,
    18
        mediaUrl: mediaUrl,
    19
        from: from,
    20
        to: to,
    21
      });
    22
      console.log(message.sid);
    23
    }
    24