Sending Media Messages#

Sending media from URL#

Media message from URL#
 1from pywa import WhatsApp
 2
 3wa = WhatsApp(phone_id='972123456789', token='xxxxx')
 4recipient = '972987654321'
 5
 6# - From URL
 7wa.send_image(
 8    to=recipient,
 9    image='https://cdn.pixabay.com/photo/2014/10/01/10/44/animal-468228_1280.jpg'
10)

Sending media from local file#

Media message from local file#
 1from pywa import WhatsApp
 2
 3wa = WhatsApp(phone_id='972123456789', token='xxxxx')
 4recipient = '972987654321'
 5
 6# - From local file
 7wa.send_video(
 8    to=recipient,
 9    video='/path/to/video.mp4'
10)

Sending media from file id#

Media message from file id#
 1from pywa import WhatsApp
 2
 3wa = WhatsApp(phone_id='972123456789', token='xxxxx')
 4recipient = '972987654321'
 5
 6audio_id = wa.upload_media(media='/path/to/audio.ogg', mime_type='audio/ogg')
 7wa.send_audio(
 8    to=recipient,
 9    audio=audio_id
10)

Sending media from bytes#

Media message from bytes#
 1from pywa import WhatsApp
 2import requests
 3
 4wa = WhatsApp(phone_id='972123456789', token='xxxxx')
 5recipient = '972987654321'
 6
 7res = requests.get('https://cdn.pixabay.com/photo/2014/10/01/10/44/animal-468228_1280.jpg')
 8wa.send_document(
 9    to=recipient,
10    document=res.content,
11    filename='animal.jpg'
12)