BitBridge messaging setup
BitBridge can be configured to use ThrillTech system events in order to dispatch messages to various channels. In order to do so, there are two required elements of configuration - dispatchers and templates.
NOTE: We provide a Postman collection which contains complete examples of payloads for the concepts described in this document here. We suggest reviewing the relevant payloads for complete examples of structures while working through this documentation
Dispatchers
Dispatchers are the entities that define the transport layer.
Currently, we support two types of transport - SMTP and Telegram.
Dispatchers explicitly list the events that they can handle.
- If an event matches more than one dispatcher, the highest priority one is selected.
- If multiple dispatchers have the same priority, they all attempt to handle the event.
operator_idandbrand_idcan be used to further narrow the list of available dispatchers for events carrying brand dimension.
This is what a SMTP dispatcher configuration looks like in the DB:
{
"id": "gmail.smtp.thrilltech",
"dispatcher_type": "Smtp",
"operator_id": "thrilltech",
"brand_id": "brand1",
"event_types": [
"ForgotPasswordStarted"
],
"enabled": true,
"config": {
"host": "smtp.gmail.com",
"user": "username",
"pass": "password"
},
"priority": 0,
"created": {
"$date": "2025-06-27T13:21:26.727Z"
},
"updated": {
"$date": "2025-06-27T13:21:26.727Z"
},
"owner_id": "thrilltech"
}
Dispatchers filtering
Dispatchers can optionally be bound to operator_id and brand_id allowing the use of different dispatchers ( email address, telegram bot ) per operator / operator:brand.
Dispatchers config
Config (defined in the .config field) is specific to the dispatcher type. Following are the examples of the two currently supported types.
SMTP:
"config": {
"host": "smtp.host.com",
"user": "username",
"pass": "password"
}
Telegram:
"config": {
"token": "xx-xx-xx"
}
Templates
Once an event matches a dispatcher, we need a suitable template to render the event. If an event matches more than one template, the highest priority one is selected. If multiple templates have the same priority, they all attempt to render the event and this results in multiple messages being sent.
Templates filtering
A template can optionally be bound to a single dispatcher, making it exclusive for that dispatcher.
A template can optionally define additional filtering rules, matching on the event data - e.g. matching a list of brands on the WinEvent.
Template filters can contain multiple nested And/Or conditions. Below you'll find common examples of such filters. When you have a use-case not covered by the examples, please contact us for assistance.
Example - filter matching only withheld wins.
"event_filter": {
"items": [
{
"Rule": {
"input_key": "data.win_withheld",
"target_value": true,
"match_mode": "BoolMatch"
}
}
],
"mode": "And"
},
Example - filter matching only wins greater than 100.
"event_filter": {
"items": [
{
"Rule": {
"input_key": "data.win_amount",
"target_value": 100,
"match_mode": "Gt"
}
}
],
"mode": "And"
},
Example - filter matching only wins that caused seed deficit.
"event_filter": {
"items": [
{
"Rule": {
"input_key": "data.seed_deficit",
"target_value": 0,
"match_mode": "Gt"
}
}
],
"mode": "And"
},
Example - filter matching only wins from brand A.
"event_filter": {
"items": [
{
"Rule": {
"input_key": "data.brand_id",
"target_value": "A",
"match_mode": "Exact"
}
}
],
"mode": "And"
},
Template subscribers
A template can explicitly list the message recipients. Depending on the template type those are:
- Telegram: chat / room identifiers
- e-mail: e-mail addresses
Template context
In some scenarios a template needs extra context, e.g. when the user triggers the Forgot Password flow and needs to receive the message on their user contact. A recipient context is then used. That context then provides the destination of the message.
Example recipient context, based on the Forgot Password event:
"context": {
"recipient": {
"Relative": "data.ForgotPasswordStarted.contacts.email"
}
},
Context can be either Relative or Absolute. Relative context uses data from the event payload. Absolute context provides its value as it is.
Template config
SMTP Template config
SMTP Template config consists of 3 values, the HTML content, plaintext content and e-mail subject. All the values do interpolation with the event payload.
"config": {
"template_html": "<html>A win was withheld! player: {{ data.player_id }}, amount: {{ data.win_amount }}, brand:{{ data.brand_id }}, withheld: {{ data.win_withheld }}</html>",
"template_plain": "Withheld win plaintext",
"template_subject": "Player {{ data.player_id }} had their win withheld!"
},
Telegram Template config
Telegram template config defines a list of messages. All messages will be sent, in the defined order. Possible message types and their corresponding data:
- Image: image url
- Video: video url
- Plaintext: text without any formatting
- Markdown: markdown formatted text, as per Telegram Markdown v2 spec
- Html: html formatted text, as per Telegram HTML rendering capabilities
All message types interpolate their data. You can use this to generate dynamic URLs for the Image / Video message types.
"config": {
"messages": [
{
"message_type": "Plaintext",
"message_data": " Player {{ data.player_id }} won the Jackpot!"
},
{
"message_type": "Video",
"message_data": "https://host.com./storage/jp_win_animation.gif"
},
{
"message_type": "Image",
"message_data": "https://host.com/storage/jp_win_{{ data.win_pot_id }}.png"
}
]
},
Template interpolation
Custom helpers functions are available in any template and can be used to transform values before they are inserted:
mask– masks sensitive strings with*charactersformat_decimal– formats numeric values with a desired precision
mask
{{mask value mask_length=4 show_first=0 show_last=0}}
mask_length- number of*characters inserted (default4)show_first- number of characters to keep from the start of the original string (default0)show_last- number of characters to keep from the end of the original string (default0)
Examples:
{{mask data.username}} => ****
{{mask data.username mask_length=6}} => ******
{{mask data.username show_first=2}} => my****
{{mask data.username show_last=2}} => ****er
{{mask data.username show_first=2 show_last=2}} => my****er
format_decimal
{{format_decimal value precision=0}}
value may be a number or a numeric string. The helper converts it to a floating point number and formats it with the desired precision.
Examples:
{{format_decimal data.amount}} => 10
{{format_decimal data.amount precision=3}} => 10.000