Pull channel
One way to deliver Insight messages is through a pull channel. It allows to retrieve the messages on demand as opposed to a push channel where messages are sent to the user's application. The advantage of the pull feed is that the messages are stored in the database and can be retrieved at any time thanks to the Feed API. For example, this allows to create a message history of push notifications or a dynamic list of widgets that can be used in a user interface dashboard. It is recommended to use a pull channel when it is required that previously generated Insight messages should still be available for fetching. Sometimes using pull channel may be the only option when the technical capabilities of the application do not allow the use of push channel.
Configuring and fetching pull channel Insight message
To configure an Insight pull message, assign a content template to the Insight definition. The content template should be assigned to the "Pull" content type channel. Once the Insights definition has been processed, it will be available in the Feed API on the endpoints:
GET /FeedApi
GET /FeedApi/{message_id}
The above endpoint allows to filter the returned messages. For example, Insight messages can be marked as displayed by using PUT /FeedAPI
. Those messages can be then filtered out using the Disaplyed
query filter. There are many other filters such as filtering by message date range, messages from inactive Insight Definitions, irrelevant messages (see Irrelevant Insights Message definition). A full list of available filters can be found in Feed API Swagger documentation.
Example
Suppose a content template exists and its dispatcher
property looks like this:
{
"Content": "<p>{{message}}</p>"
}
There is also an active Insight Definition with the above content template assigned and the data model defined, as below:
{
"message": "Hi {{@r.UserRepository.PersonFirstName()}}, you've made a transaction for the amount of {{@e.Amount}} {{@e.Currency}}"
}
When the above Insight Definition has been processed for a user, then the GET /FeedApi
endpoint may return a message like the following:
{
"data": [{
"id": "00100000-ac16-0242-8fe1-08da49eaa7c9",
"content":"{\"Content\":\"<p>Hi Joe, you've made a transaction for the amount of -17.0000 EUR</p>\"}",
"contentAsJson":"{\"message":"Hi Joe, you\\u0027ve made a transaction for the amount of -17.0000 EUR\"}",
"channel": "web_app_pull",
"goal": "Educate",
"category": "Savings",
"contentType": "Plain text",
"contentTemplate": "Simple plain text message message",
"date": "2022-06-09T07:35:41.2633333"
}
],
"totalCount": 1
}
In the above result, the content
property represents the rendered value based on the content template property dispatcher
. The contentAsJson
property represents the rendered data model from the Insights Definition content template that was used to render the message content. For more information on how Insights Messages are rendered, see here.