Package 'twilio'

Title: An Interface to the Twilio API for R
Description: The Twilio web service provides an API for computer programs to interact with telephony. The included functions wrap the SMS and MMS portions of Twilio's API, allowing users to send and receive text messages from R. See <https://www.twilio.com/docs/> for more information.
Authors: Sean Kross [aut, cre]
Maintainer: Sean Kross <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-12-22 03:02:13 UTC
Source: https://github.com/seankross/twilio

Help Index


Get Media from a Message

Description

Media items that are attached to MMS messages, including photos and videos are stored by Twilio. This function returns a list of twilio_media objects, one for each piece of media in an MMS. Each object contains information about that piece of media including its URL, Media SID, and content type.

Usage

tw_get_message_media(message_sid)

Arguments

message_sid

An SID for a message that contains media.

Value

A list containing media information.

Examples

## Not run: 

# Set API credentials
# You only need to do this once per R session
Sys.setenv(TWILIO_SID = "M9W4Ozq8BFX94w5St5hikg7UV0lPpH8e56")
Sys.setenv(TWILIO_TOKEN = "483H9lE05V0Jr362eq1814Li2N1I424t")

# Get media information from a message
tw_get_message_media("MMo8Jw86Lj6422NzWgb8QxXlD5c45U100v")


## End(Not run)

Get List of Messages Sent and Received from Your Account

Description

Retrieves a list of Twilio SMS and MMS messages sent and receieved from your account.

Usage

tw_get_messages_list(page = 0, page_size = 50)

Arguments

page

The page number of the list you would like to retrieve. Starts at zero.

page_size

The number of messages per page. The maximum number allowed is 1000.

Value

A twilio_messages_list object.

Examples

## Not run: 

# Set API credentials
# You only need to do this once per R session
Sys.setenv(TWILIO_SID = "M9W4Ozq8BFX94w5St5hikg7UV0lPpH8e56")
Sys.setenv(TWILIO_TOKEN = "483H9lE05V0Jr362eq1814Li2N1I424t")

# Get messages sent to your account
messages <- tw_get_messages_list()


## End(Not run)

Make a Data Frame from a Messages List

Description

Useful for turning a twilio_messages_list into a tidy data set.

Usage

tw_message_tbl(messages_list)

Arguments

messages_list

An S3 object with the class twilio_messages_list. Likely the result of a call to tw_get_messages_list.

Value

A data frame.

Examples

## Not run: 

# Set API credentials
# You only need to do this once per R session
Sys.setenv(TWILIO_SID = "M9W4Ozq8BFX94w5St5hikg7UV0lPpH8e56")
Sys.setenv(TWILIO_TOKEN = "483H9lE05V0Jr362eq1814Li2N1I424t")

# Get messages sent to your account
messages <- tw_get_messages_list()

# Create data frame from log
sms_data <- tw_message_tbl(messages)


## End(Not run)

Send an SMS or MMS Message

Description

Send an SMS or MMS Message

Usage

tw_send_message(to, from, body = NULL, media_url = NULL)

Arguments

to

A phone number which will receieve the message.

from

A phone number which will send the message.

body

The body of the message.

media_url

A url containing media to be sent in a message.

Value

A twilio_message object.

Examples

## Not run: 

# Set API credentials
# You only need to do this once per R session
Sys.setenv(TWILIO_SID = "M9W4Ozq8BFX94w5St5hikg7UV0lPpH8e56")
Sys.setenv(TWILIO_TOKEN = "483H9lE05V0Jr362eq1814Li2N1I424t")

# Send a simple text message
tw_send_message("2125557634", "9178675903", "Hello from R!")

# Send a picture message
tw_send_message("2125557634", "9178675903", media_url = "https://www.r-project.org/logo/Rlogo.png")

# Send a picture message with text
tw_send_message("2125557634", "9178675903", "Do you like the new logo?",
    "https://www.r-project.org/logo/Rlogo.png")


## End(Not run)