Does Python twilio.rest Client support media messages?
I've had some success creating and receiving media messages with JavaScript, outlined here https://www.twilio.com/docs/chat/media-support
I'm wondering if there is support for this in the python client? As far as I can tell, it only allows a string for the body e.g.
channel.messages.create(from_='someone', body='The message body')
whereas the JavaScript allows media
channel.sendMessage({contentType: 'application/json', media: {'number': 42},});
Answers
-
Ah you are crossing concerns a bit here. The REST APIs Python/JS/etc do not have the ability to create media:
- Node module - https://github.com/twilio/twilio-node/blob/1f0a03f2ad6479ad3c8e4794a408a836bfb343d0/lib/rest/chat/v2/service/channel/message.js#L94-L102
- Python module - https://github.com/twilio/twilio-python/blob/50a9a4a792c7d645a3d1b1e54f78af59c3fc6509/twilio/rest/chat/v2/service/channel/message.py#L56-L64
The API call channel.sendMessage(...) is part of the client SDK package (http://media.twiliocdn.com/sdk/js/chat/releases/4.0.0/docs/Channel.html#sendMessage__anchor). If you really wanted to use a backend system to place media you would want to look at [Create/Upload a new Media Resource](https://www.twilio.com/docs/chat/rest/media#createupload-a-new-media-resource) and that should return a media_sid which you could use with the Python SDK.
Categories
- 83 All Categories
- 19 SIGNAL 2021
- 376 Product Discussions
- 7 Community - Announcements
- 2 Changelog
- 4 Forum UI Updates
- 8 Welcome Guide
- 6 Community - Events
- 2 Twilio Relay Developer Conference 2021 Mega Thread
- 1 External Community Events
- 25 Inspiration
- 17 Community - Other Discussions
- 1 Community- Twilio Startups