Skip to content

New template based "custom" channel to replace external channels #380

@rowanseymour

Description

@rowanseymour

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)
)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions