Channel
OCP App SDK / Channel
Class: abstract
Channel
abstract
ChannelDefined in: src/app/Channel.ts:16
Defines the interface of a channel. The typical channel flow in a campaign run is as follows:
- Check if the channel is
ready
to use - Dynamically determine the
target
(may be provided statically inapp.yml
instead) publish
the content template (in the future, this will instead happen when the campaign is modified)prepare
for the run (if the method is implemented)deliver
the content to batches of recipients with substitutions
Outside of the campaign run flow, a channel must also be able to preview
a given piece of content for a batch
of recipients.
Constructors
Constructor
new Channel():
Channel
Returns
Channel
Methods
deliver()
abstract
deliver(contentKey
,tracking
,options
,batch
,previousResult?
):Promise
<ChannelDeliverResult
>
Defined in: src/app/Channel.ts:107
Delivers a batch of messages. This method may be called many times for the same content key, tracking parameters,
and options, each with a unique batch of recipients and substitutions. It is assumed that a batch either succeeds
or fails as a whole. There is no partial delivery handling.
If a batch fails, it may be retried (as controlled by the return value). When that happens, the subsequent call(s) for that batch will be given the previous result for reference to enable proper recovery logic.
Once a batch succeeds, it will never be given again.
Parameters
contentKey
string
unique key of the content
tracking
campaign tracking parameters
options
additional options
batch
of recipients and substitutions
previousResult?
previous result of the operation, if this is a retry
Returns
Promise
<ChannelDeliverResult
>
result of the operation
Async
prepare()?
optional
prepare(contentKey
,tracking
,options
):Promise
<ChannelPrepareResult
>
Defined in: src/app/Channel.ts:86
Prepares for a campaign run. This can be used to set up an external entity for use in deliver
(or perform any
other processing that should only be performed once per run). If this step is unnecessary, simply do not implement
the method.
If implemented, this method will be called exactly once per content key involved in a campaign run. If any one of these fails, the campaign run will fail.
Parameters
contentKey
string
unique key of the content
tracking
campaign tracking parameters
options
additional options
Returns
Promise
<ChannelPrepareResult
>
result of the operation
Async
preview()
abstract
preview(content
,batch
):Promise
<ChannelPreviewResult
>
Defined in: src/app/Channel.ts:123
Renders a batch of messages into HTML previews. Each preview must be a full HTML page containing a user-friendly
representation of the message as it would be delivered.
Parameters
content
the content with translated templates
batch
of recipients and substitutions
Returns
Promise
<ChannelPreviewResult
>
result of the operation
Async
publish()
abstract
publish(contentKey
,content
,options
):Promise
<ChannelContentResult
>
Defined in: src/app/Channel.ts:69
Publishes the given content. This is the place to perform any necessary transformations between the given template
format and the external system's format. It can be assumed that Channel.validate has already been called,
but additional errors may still be detected in this phase and returned in the same way as during validation.
If the content must be stored in an external system, this is also the time to do that. If the content must instead be known in `prepare` or `deliver`, it should be placed in the document store for future use.
This method may be called multiple times with the same content key. But for a given content key, it will always be called with the same content and options. As such, once successful, it should be treated as an idempotent operation at the content key level. So if the given key has already been processed and successfully stored, there is no need to process and store it again.
Parameters
contentKey
string
unique key for the content
content
the content with translated templates
options
additional options
Returns
Promise
<ChannelContentResult
>
result of the operation
Async
ready()
abstract
ready():Promise
<boolean
>
Defined in: src/app/Channel.ts:23
Checks if the channel is ready to use. This should ensure that any required credentials and/or other configuration
exist and are valid. Reasonable caching should be utilized to prevent excessive requests to external resources.
Returns
Promise
<boolean
>
true if the channel is ready to use
Async
target()?
optional
target(contentSettings
):Promise
<ChannelTargetResult
>
Defined in: src/app/Channel.ts:34
Dynamically determines campaign targeting requirements. It should also perform any necessary validations on the
input data. If targeting is always known ahead of time, this should be specified statically via channel.targeting
in app.yml
. If targeting is based on selections made in the content settings form, this method must be
implemented and the value in app.yml
must be set to dynamic
.
Parameters
contentSettings
FormData
data from the content settings form
Returns
Promise
<ChannelTargetResult
>
result of the operation
Async
templatePreview()
templatePreview(
template
):Promise
<ChannelTemplatePreviewResult
>
Defined in: src/app/Channel.ts:136
Renders an untranslated template (containing Liquid code rather than substitution identifiers) to HTML to be
used for thumbnail creation for users to browse templates for this channel. Thumbnails will be generated at
resolution of 600px by 600px with a 50% scale factor (actual size 300px by 300px).
Parameters
template
FormData
the untranslated template
Returns
Promise
<ChannelTemplatePreviewResult
>
result of the operation
Async
validate()
abstract
validate(content
,options
):Promise
<ChannelContentResult
>
Defined in: src/app/Channel.ts:47
Validates the given content. This should ensure that the content is suitable for use in the current mode, as
specified in the options (see ChannelValidateOptions.mode). If specific fields are missing or invalid,
appropriate error messages should be provided using ChannelContentResult.addError. Any errors that are
not linked to a specific field should be provided using ChannelContentResult.addToast. If no errors of
either type are returned, the validation is considered successful, and the operation will be allowed to proceed.
Parameters
content
the content with translated tempaltes
options
additional options
Returns
Promise
<ChannelContentResult
>
result of the operation
Async
Updated 3 days ago