The existing external/EX channel type is getting a bit unwieldy and still lacks attachment support. We could introduce a new "custom" channel type which uses the same templates/expressions that users are familiar with from flows...
- incoming payloads are assumed to be JSON or converted to a JSON representation, e.g. a URL encoded payload like
?text=Hello+World can be converted to {"text": "Hello World"}
- fields are extracted from that JSON using excellent expressions
For example a channel sends...
{
"from": "+124215151",
"text": "Hello",
"media": [{"content_type": "image", "url": "http://example.com/test.jpg"}]
}
And the channel extracts from, text and attachments from that using 3 expressions:
- from:
@("tel:" & body.from)
- text:
@body.text
- attachments:
@(foreach(body.media, extract, "url"))
For outgoing messages, users again use expressions for the URL and body, e.g.
- url:
http://mychannel.com/send/@channel.uuid
- body:
@(json(object(
"from": channel.address,
"to": msg.to.path,
"text": msg.text,
"media": foreach(msg.attachments, attachment_parts)
)))
The existing external/EX channel type is getting a bit unwieldy and still lacks attachment support. We could introduce a new "custom" channel type which uses the same templates/expressions that users are familiar with from flows...
?text=Hello+Worldcan be converted to{"text": "Hello World"}For example a channel sends...
{ "from": "+124215151", "text": "Hello", "media": [{"content_type": "image", "url": "http://example.com/test.jpg"}] }And the channel extracts
from,textandattachmentsfrom that using 3 expressions:@("tel:" & body.from)@body.text@(foreach(body.media, extract, "url"))For outgoing messages, users again use expressions for the URL and body, e.g.
http://mychannel.com/send/@channel.uuid