Ir para o conteúdo

botcity.plugins.twilio.sms.plugin.BotTwilioSMSPlugin

phone_number: str property writable

The phone number that will be used to send messages.

__init__(self, account_sid, auth_token, phone_number) special

BotTwilioSMSPlugin.

Parameters:

Name Type Description Default
account_sid str

The unique Account Sid of your Twilio account.

required
auth_token str

The unique Auth Token of your Twilio account.

required
phone_number str

A number that is active on your Twilio account to be used for sending messages. The number must be informed in this format: [+][country code][phone number including area code]

required

download_media_file(self, msg, download_folder_path=None)

Download media contents from a SMS message and save on disk.

Parameters:

Name Type Description Default
msg MessageInstance

The message that contains a media content.

required
download_folder_path str

The folder where the files will be saved. Defaults to the current working directory.

None

get_received_messages(self, from_number=None, before_date=None, after_date=None, on_date=None, limit=None)

Get all SMS messages that were received by the configured phone number.

Parameters:

Name Type Description Default
from_number str

Filters messages that were received only from this number.

None
before_date datetime

Filters messages that were received before this specific date.

None
after_date datetime

Filters messages that were received after this specific date.

None
on_date datetime

Filters messages that were received on this specific date.

None
limit int

The maximum number of messages that will be returned.

None

Returns:

Type Description
List[MessageInstance]

The list containing the messages found.

get_sent_messages(self, to_number=None, before_date=None, after_date=None, on_date=None, limit=None)

Get all SMS messages that were sent by the configured phone number.

Parameters:

Name Type Description Default
to_number str

Filters messages that were sent only to this number.

None
before_date datetime

Filters messages that were sent before this specific date.

None
after_date datetime

Filters messages that were sent after this specific date.

None
on_date datetime

Filters messages that were sent on this specific date.

None
limit int

The maximum number of messages that will be returned.

None

Returns:

Type Description
List[MessageInstance]

The list containing the messages found.

reply_sms(self, msg, text_content, media_urls=None)

Reply to a previously received SMS message.

Parameters:

Name Type Description Default
msg MessageInstance

The message to reply.

required
text_content str

The body of the reply message.

required
media_urls List[str]

The URLs of media contents that will be sent in the message.

None

send_sms(self, to_number, msg_content, media_urls=None)

Sends an SMS message to the specified phone number. The to_number must be informed in this format: [+][country code][phone number including area code]

Parameters:

Name Type Description Default
to_number str

The phone number that will receive the message.

required
msg_content str

The message body content.

required
media_urls List[str]

The URLs of media contents that will be sent in the message.

None

wait_for_new_sms(self, from_number=None, timeout=60)

Wait for a new SMS message until a timeout.

Parameters:

Name Type Description Default
from_number str

Wait for a new message from this specific number. Defaults to any new message.

None
timeout int

The maximum waiting time (in seconds). Defaults to 60s.

60

Returns:

Type Description
MessageInstance

The new message received. None otherwise.