Type Definitions
# OnActionInterface
Defines the structure of an action object that can be dispatched in the application. Each action includes:
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
type |
string | number |
<required> |
A string literal from TriggerActionEnum signifying the kind of event (e.g., 'Close', 'Click', 'BetConciergeOutcome'). |
data |
string | Object | An optional payload that provides additional information needed to handle the action. This can be an object, string, or undefined if no extra data is needed. |
Example
// A complete switch-case example illustrating multiple action types:
onAction: function(action) {
switch (action.type) {
case 'Close': {
const { data } = action;
// ... implement logic to close the widget
break;
}
case 'Click': {
const { data } = action;
// ... implement logic for handling terms link or statistics link clicks
break;
}
case 'Error': {
const { data } = action;
// ... implement logic for handling widget errors
break;
}
case 'BetConciergeOutcome': {
const { data } = action;
// ... implement logic for handling clicks on AI market suggestions
break;
}
// ... add new cases here for other actions
default:
// Handle unknown or unanticipated action types
console.warn(`Unknown action type: ${action.type}`);
break;
}
}
# WidgetProps
Properties passed to the Bet Concierge widget, on initialization.
⚠️ IMPORTANT AUTHENTICATION REQUIREMENT: You MUST provide ONE of the following authentication methods:
jwt(string) - Direct JWT token, ORgetJwt(function) - Callback function that returns JWT token
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
matchId |
string | number |
<required> |
Sportradar ID of the match. |
jwt |
string | User's JWT Token for authentication. You MUST provide either |
|
getJwt |
getJwt Widgets.BetConcierge.Integration.TechnicalGuide.getJwt | A callback promise function that returns user's JWT Token for authentication. You MUST provide either |
|
onAction |
function | OnActionInterface Widgets.BetConcierge.Integration.TechnicalGuide.OnActionInterface | Handles application-wide actions by routing them to the appropriate logic based on the action type. |
|
numberOfSuggestedQuestions |
range(3, 5) | Number of AI suggested questions in each category. |
|
disableChatHistory |
boolean | When set to |
|
enableCustomBet |
boolean | Set this prop to true when implementing Custom Bet feature. This will enable |
|
termsPage |
'hidden' | 'visible' | 'visibleOnEmptyChat' | Terms and conditions page is meant to be displayed on the widget load. When user clicks on |
|
enableTermsLink |
boolean | When set to |
|
disableHomeLink |
boolean | When set to |
|
disableCoverage |
boolean | When set to |
|
disableHeader |
boolean | When set to |
|
enableMarketQuestions |
boolean | When set to |
|
enableInsights |
boolean | When set to |
Example
defaultProps = {
disableHeader: false,
disableHomeLink: false,
numberOfSuggestedQuestions: 3,
enableTermsLink: false,
termsPage: 'hidden',
disableChatHistory: false,
enableCustomBet: false,
enableMarketQuestions: false,
enableInsights: true
}
# getJwt()
Defines the structure of a callback promise function that retrieves a JWT token for user authentication. This function gets called when the Bet Concierge widget is initialized and when token refresh is needed.
Example
// Example implementation of getJwt function:
function getJwt() {
return fetch("https://example.com/api/get-jwt/user123")
.then((response) => response.json())
.then((data) => data.token); // Must resolve to the JWT string - assuming backend returns { "token": "..." }
}