¶
botcity.plugins.twilio.whatsapp.BotTwilioWhatsappPlugin
¶
whatsapp_number
property
writable
¶
The Whatsapp number that will be used to send messages.
__init__(account_sid, auth_token, whatsapp_number)
¶
BotTwilioWhatsapp.
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 |
whatsapp_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(msg, download_folder_path=None)
¶
Download the media content from a 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 file will be saved. Defaults to the current working directory. |
None
|
get_received_messages(from_number=None, before_date=None, after_date=None, on_date=None, limit=None)
¶
Get all messages that were received by the configured Whatsapp 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]
|
List[MessageInstance]: The list containing the messages found. |
get_sent_messages(to_number=None, before_date=None, after_date=None, on_date=None, limit=None)
¶
Get all messages that were sent by the configured Whatsapp 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]
|
List[MessageInstance]: The list containing the messages found. |
reply_message(msg, text_content, media_url=None)
¶
Reply to a previously received message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
MessageInstance
|
The message to reply. |
required |
text_content
|
str
|
The body of the reply message. |
required |
media_url
|
str
|
The URL of a media content that will be sent in the message. |
None
|
send_message(to_number, msg_content, media_url=None)
¶
Sends an message via Whatsapp to the specified 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 Whatsapp number that will receive the message. |
required |
msg_content
|
str
|
The message body content. |
required |
media_url
|
str
|
The URL of a media content that will be sent in the message. |
None
|
wait_for_new_message(from_number=None, timeout=60)
¶
Wait for a new 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:
| Name | Type | Description |
|---|---|---|
MessageInstance |
MessageInstance
|
The new message received. None otherwise. |