### Install with npm
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/install-brand-messenger-react-native-sdk
Use this command to install the SDK using npm.
```bash
npm install react-native-brandmessenger-sdk
```
--------------------------------
### Install with yarn
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/install-brand-messenger-react-native-sdk
Use this command to install the SDK using yarn.
```bash
yarn add react-native-brandmessenger-sdk
```
--------------------------------
### Complete AndroidManifest.xml Example
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/install-brand-messenger-android-sdk
A full example of how the manifest file should be structured with all required components and namespace declarations.
```xml
```
--------------------------------
### cURL Request Example
Source: https://developer.khoros.com/khorosmarketingdevdocs/reference/get-specified-sort-order
Demonstrates how to make a GET request to the API endpoint to fetch meta data with a specified sort order. Ensure to replace 'account' and 'streamName' with your actual values.
```shell
curl --request GET \
--url 'https://api.massrelevance.com/account/streamName/meta.json?sort=' \
--header 'accept: text/plain'
```
--------------------------------
### Installation
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-flutter-sdk
Instructions for adding the Brand Messenger Flutter SDK to your project and installing dependencies.
```APIDOC
## Installation
Add the following to your project's **pubspec.yaml** `dependencies`:
```yaml
flutter_brandmessenger_sdk:
git:
url: git@github.com:lithiumtech/flutter_brandmessenger_sdk.git
ref: main
```
Run the following command to download the flutter **sdk** plugin:
```powershell
flutter pub get
```
Run the following in the `/ios` directory to download iOS framework:
```powershell
pod install
```
```
--------------------------------
### Launch Chat Screen
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-ios-sdk-conversation
Implement this code in an event or button action to launch the Chat screen. Ensure all necessary permissions from the Installation guide are added.
```swift
BrandMessengerManager.show(self)
```
```objectivec
[BrandMessengerManager show:self];
```
--------------------------------
### Intent Matching Examples for Calculation
Source: https://developer.khoros.com/khoros-flow/docs/code-based-actions-conversational-calculator
Use these examples to train your intent to recognize user requests for calculations. Ensure your intent is configured to capture numerical entities.
```NLU
Do you understand math?
```
```NLU
Can you calculate something for me?
```
```NLU
What is 8 divided by 4?
```
```NLU
8/4=?
```
--------------------------------
### Retrieve an asset via cURL
Source: https://developer.khoros.com/khorosmarketingdevdocs/reference/get-an-asset
Example request for fetching an asset using the GET method.
```Shell
curl --request GET \
--url 'https://your-domain.com/asset/assetPath?thumbnail=false' \
--header 'accept: text/plain'
```
--------------------------------
### Install BrandMessenger via Podfile
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/ios-custom-ui-quickstart
Add the BrandMessenger dependency to your Podfile and run pod install to integrate the framework.
```ruby
source 'https://github.com/CocoaPods/Specs'
use_frameworks! # Required to add
platform :ios, '12.0' # Required to add
target 'TARGET_NAME' do
pod 'BrandMessenger', '1.16.4' # Required to add
end
```
--------------------------------
### Example Account API Request
Source: https://developer.khoros.com/khorosmarketingdevdocs/reference/stream-api
Example of a cURL request to the Account API, specifying multiple streams for the MassRelDemo account.
```bash
$ curl http://api.massrelevance.com/MassRelDemo.json?streams=galaxy-topic1,galaxy-topic2,galaxy-topic3
```
--------------------------------
### Example Leaderboard API Requests
Source: https://developer.khoros.com/khorosmarketingdevdocs/reference/stream-api
Examples of requests to retrieve different types of ranked data from the Leaderboard API.
```URL
http://api.massrelevance.com/massreldemo/kindle/top_hashtags.json
```
```URL
http://api.massrelevance.com/massreldemo/kindle/top_urls.json
```
```URL
http://api.massrelevance.com/massreldemo/kindle/top_terms.json
```
```URL
http://api.massrelevance.com/massreldemo/kindle/top_user_mentions.json
```
```URL
http://api.massrelevance.com/massreldemo/constrained-topics-food/top_constrained_topics.json
```
--------------------------------
### Media Object Example
Source: https://developer.khoros.com/khoroscaredevdocs/reference/media-object
This is an example of a Media object. It includes the URL of the media and its type. The mediaType can be IMAGE or VIDEO.
```json
{
"url": "https://pics.example.com/image.jpg",
"mediaType": "IMAGE"
}
```
--------------------------------
### Fetching Configuration Value
Source: https://developer.khoros.com/khoros-flow/docs/configuration
Use the `get()` method to fetch the key value. If there are no data available, the `get()` method returns a `null` value.
```APIDOC
## GET /config/get
### Description
Retrieves a configuration value by its key.
### Method
GET
### Endpoint
/config/get
### Parameters
#### Query Parameters
- **key** (string) - Required - The key used to find the data.
### Request Example
```
GET /config/get?key=secret_key
```
### Response
#### Success Response (200)
- **promise** (string) - A promise that is resolved with the value being stored or null if the key does not exist.
#### Response Example
```json
{
"key": "secret_key",
"value": "your_secret_value"
}
```
```
--------------------------------
### Example Bot API Callback URL
Source: https://developer.khoros.com/khoroscaredevdocs/reference/api-callbacks-to-bots
This is an example of the GET request URL that the Bot API invokes to send a callback to the bot. It includes query parameters for conversation details.
```url
https://?conversationDisplayId=5050505&externalId=123456789&authorId=9090909&network=facebook
```
--------------------------------
### GET /{account}.json
Source: https://developer.khoros.com/khorosmarketingdevdocs/reference/get-activity-data-from-specific-time
Retrieves activity data for a specific account starting from a defined Unix timestamp.
```APIDOC
## GET /{account}.json
### Description
Retrieves activity data for a specific account starting from a defined Unix timestamp. The start parameter represents the seconds portion of Unix time.
### Method
GET
### Endpoint
https://api.massrelevance.com/{account}.json
### Parameters
#### Path Parameters
- **account** (string) - Required - The account identifier.
#### Query Parameters
- **start** (int32) - Optional - Unix time of the point at which activity data should start. Defaults to 1349278694.
### Request Example
curl --request GET \
--url 'https://api.massrelevance.com/account.json?start=' \
--header 'accept: application/json'
### Response
#### Success Response (200)
- **200** - Successful retrieval of activity data.
```
--------------------------------
### Get Object Fields (cURL)
Source: https://developer.khoros.com/khorosmarketingdevdocs/reference/define-object-structures
Example cURL command to retrieve the defined fields for a specific object type (e.g., 'customer' or 'case').
```shell
curl --request GET \
--url https://your-domain.com/meta/object/type \
--header 'accept: text/plain'
```
--------------------------------
### Initialize the SDK
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/authentication-and-authorization-in-ios
Initialize the SDK using your Company Key and App ID, or optionally with a Widget ID.
```Swift
BrandMessengerManager(companyKey: company-key, applicationKey: application-key)
// Or if you do not have the application key or want to use widget configuration in the SDK
BrandMessengerManager(companyKey: company-key, applicationKey: nil, widgetId: widget-id, completion: { response, error in
if error != nil {
//init success
}
//do something with error
})
```
```Objective-C
@import BrandMessengerUI
// Call it only once in your app.
[[BrandMessengerManager alloc] initWithCompanyKey:@"" applicationKey:@""];// Replace this with your Company Key and App ID
// Or if you do not have the application key or want to use widget configuration in the SDK
[[BrandMessengerManager alloc] initWithCompanyKey:@"" applicationKey:nil widgetId:@"" completion:^(BOOL response, NSError * _Nullable error) {
if (error != nil) {
//init success
}
// do something with error
}];
```
--------------------------------
### Initialize SDK
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/authentication-and-authorization-in-android
Initialize the SDK using company and application keys or widget configuration.
```Java
BrandMessengerManager.init(this, BrandMessenger.getInstance(this).getCompanyKey(), BrandMessenger.getInstance(this).getApplicationKey());
// Or if you do not have the application key or want to use widget configuration in the SDK
BrandMessengerManager.init(this, "companyKey", "", "widgetId", new KBMCallback() {
@Override
public void onSuccess(Object response) {
}
@Override
public void onError(Object error) {
}
});
```
```Kotlin
BrandMessengerManager.init(context, BrandMessenger.getInstance(context).companyKey, BrandMessenger.getInstance(context).applicationKey)
```
--------------------------------
### Launch Chat with Welcome Message
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-ios-sdk-conversation
Use this method to launch the Chat screen and send a welcome message if the environment is configured with Welcome-Messages.
```swift
BrandMessengerManager.showWithWelcome(vc: UIViewController?)
```
--------------------------------
### Monitor Unread Count Changes
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-flutter-sdk
Start monitoring for local changes to the unread message count. This is useful for updating the count in real-time, for example, after receiving a push notification.
```Dart
App.bmsdk.monitorUnreadCount();
```
--------------------------------
### Download SDK and iOS Framework
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-flutter-sdk
Commands to fetch the Flutter plugin and the required iOS framework.
```powershell
flutter pub get
```
```powershell
pod install
```
--------------------------------
### Generate Analytics Report Exports
Source: https://developer.khoros.com/khoroscaredevdocs/docs/get-started-with-the-analytics-reports-api
Use cURL to initiate a GET request for a report. The first example requests a CSV format, while the second requests specific metrics in JSON format.
```bash
curl -u '[USERNAME]:[PASSWORD]' -XGET 'https://analytics-api.app.lithium.com/api/public/reports/report/conversation?reportFormat=csv&locale=en_US&companyKey=[COMPANY_KEY]&startTime=1551441600000&endTime=1556712000000
```
```bash
curl -u '[USERNAME]:[PASSWORD]' -XGET 'https://analytics-api.app.lithium.com/api/public/reports/report/conversation?locale=en_US&companyKey=[COMPANY_KEY]&startTime=1551441600000&endTime=1556712000000&reportMetrics=CONVERSATION_ID&reportMetrics=STATUS&reportMetrics=ASSIGNED_AGENT_DISPLAY_ID'
```
--------------------------------
### Initiate Chat with Agent (Java)
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-android-sdk-conversation
Use this method to start the messaging activity. Ensure the Brand Messenger SDK is properly initialized.
```java
BrandMessengerManager.show(context);
```
--------------------------------
### Create an Article Webview
Source: https://developer.khoros.com/khoros-flow/docs/article
Initializes a basic article webview with a reference, title, and plain text content.
```javascript
const url = await webview.article.create({
ref: 'news-item',
title: 'Hello world',
content: `Lorem ipsum dolor sit amet, consectetur adipiscing elit.`
})
```
--------------------------------
### Generate Conversation Actions Report
Source: https://developer.khoros.com/khoroscaredevdocs/reference/reportsreportconversation_actions-1
Example of a cURL request to generate a conversation actions report. This includes setting the start and end times, timezone offset, business hour enablement, locale, time interval, and timezone.
```shell
curl -u [USERNAME]:[PASSWORD] -XPOST \
'https://analytics-api.app.lithium.com/api/public/reports/report/conversation_actions?companyKey=[COMPANY_KEY]' \
-d 'startTime=1548979200000&endTime=1556668800000&timezoneOffset=-21600000&enableBusinessHour=true&locale=en&timeInterval=86400000&timezone=America%2FChicago'
```
--------------------------------
### Get Object Structure - cURL Request
Source: https://developer.khoros.com/khoroscaredevdocs/reference/define-object-structures
Example cURL command to retrieve the defined object structure for a specified type (e.g., 'customer' or 'case'). Ensure to replace '{your-domain}' and '{type}' with your actual domain and the desired object type.
```shell
curl --request GET \
--url https://your-domain.com/meta/object/type \
--header 'accept: application/json'
```
--------------------------------
### Define a Profile Object
Source: https://developer.khoros.com/khoros-flow/docs/originator-object
Examples showing how to include detailed profile information or metadata within the originator object.
```json
{
"type": "message.send",
"payload": {
"threadId": "EXAMPLE27348ed3bd1439e7b",
"traceId": 1111111111111,
"speech": "has my milk expired?",
"originator": {
"name": "John Doe",
"role": "external",
"profile": {
"fullName": "John Doe",
"firstName": "John",
"lastName": "Doe",
"gender": "M",
"locale": "en-US",
"timezone": -5,
"country": "us",
"email": "EXAMPLE@dmail.com",
"picture": "https://..."
}
}
}
}
```
```json
{
"type": "message.send",
"payload": {
"threadId": "EXAMPLE27348ed3bd1439e7b",
"speech": "I want to book a flight between Amsterdam and Toronto",
"originator": {
"name": "John Doe",
"role": "external",
"metadata": {
"clientNumber": "asddaasq333ee332",
"preference": "A,B,G"
}
}
}
}
```
--------------------------------
### Message Event Example
Source: https://developer.khoros.com/khoroscaredevdocs/reference/incoming-message-payloads-channel-to-bot
An example of a standard message event payload.
```APIDOC
## Message Event
### Response Example
```json
{
"coordinate":{
"companyKey":"...",
"networkKey":"whatsapp",
"externalId":"5de...",
"messageId":"5e2...",
"botId":"bot-id",
"scope":"PRIVATE",
"normalizedAuthorId":"3a4..."
},
"text":"hello",
"author":{
"id":"3a4...",
"fullName":"Jo",
"properties":{
}
},
"owner":{
"type":"AGENT"
},
"publishedTS":1579793945986,
"receivedTS":1579793946280,
"properties":{
},
"type":"message"
}
```
```
--------------------------------
### Initialize CocoaPods Project
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/install-brand-messenger-ios-sdk
Run this command in your project's root directory to initialize CocoaPods.
```shell
pod init
```
--------------------------------
### Initialization
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-flutter-sdk
Steps to initialize the Brand Messenger SDK with company and application details.
```APIDOC
## Initialization
To initialize Brand Messenger and connect to the correct company instance, you need the `companyKey` and `applicationId` and optional `WidgetId`. Please contact Khoros Support to request these for your company.
First, initialize with `companyKey` and `applicationId`:
```dart
App.bmsdk.initWithCompanyKeyAndApplicationId("", "");
```
or, initialize with `companyKey`, `applicationId` and `widgetId`:
```dart
App.bmsdk.initWithCompanyKeyApplicationIdWidgetId("", "", "");
```
If your application uses a non-default module-name, you also need to set `AppModuleName` on the SDK.
```dart
App.bmsdk.setAppModuleName("");
```
You can also set `widgetId` separately:
```dart
App.bmsdk.setWidgetId("");
```
```
--------------------------------
### Created Conversation Event Example
Source: https://developer.khoros.com/khoroscaredevdocs/reference/incoming-message-payloads-channel-to-bot
An example of a created conversation event payload.
```APIDOC
## Created Conversation Event
### Response Example
```json
{
"coordinate":{
"companyKey":"...",
"networkKey":"whatsapp",
"externalId":"5de...",
"messageId":"5e2...",
"botId":"5a3...",
"scope":"PRIVATE",
"normalizedAuthorId":"05..."
},
"author":{
"id":"05...",
"fullName":"name"
},
"operation":"CREATED",
"conversation":{
"displayId":123,
"dispositionId":0,
"encodedDispositionId": 0,
"conversationUuid": "3de...."
},
"type":"update"
}
```
```
--------------------------------
### Style Welcome Screen Introduction Text
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/advanced-css-classes
Applies a red border to the introductory text within the Welcome Screen.
```CSS
.khWelcomeScreenIntroduction {
border: 2px solid red;
}
```
--------------------------------
### Closed Conversation Event Example
Source: https://developer.khoros.com/khoroscaredevdocs/reference/incoming-message-payloads-channel-to-bot
An example of a closed conversation event payload.
```APIDOC
## Closed Conversation Event
### Response Example
```json
{
"coordinate":{
"companyKey":"...",
"networkKey":"apple",
"externalId":"5bb...",
"botId":"ABCBot",
"scope":"PRIVATE",
"normalizedAuthorId":"urn:mbid:AQ..."
},
"author":{
"id":"urn:mbid:AQ...",
"fullName":"Anonymous Stork 1afc-9b12"
},
"operation":"CLOSED",
"conversation":{
"displayId":5178076,
"dispositionId":19,
"encodedDispositionId": 320,
"conversationUuid": "3de...."
},
"type":"update"
}
```
```
--------------------------------
### Initialize Brand Messenger with New Method
Source: https://developer.khoros.com/khorosbrandmessengerdocs/changelog/brand-messenger-android-sdk-1130
Use this new initialization method to set up the Brand Messenger SDK. It allows for additional parameters like widget ID and a callback for success or error handling.
```java
BrandMessengerManager.init(context, "company-key", "", "some-widget-id", new KBMCallback() {
@Override
public void onSuccess(Object response) {
// on successful initialization, you can call login here
}
@Override
public void onError(Object error) {
}
});
```
--------------------------------
### Configure SDK Initialization
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-flutter-sdk
Initialize the SDK with company credentials and optional module or widget identifiers.
```dart
App.bmsdk.initWithCompanyKeyAndApplicationId("", "");
```
```dart
App.bmsdk.initWithCompanyKeyApplicationIdWidgetId("", "", "");
```
```dart
App.bmsdk.setAppModuleName("");
```
```dart
App.bmsdk.setWidgetId("");
```
--------------------------------
### Create Customer Request (cURL)
Source: https://developer.khoros.com/khorosmarketingdevdocs/reference/createcustomer
Use this cURL command to create a new customer. Ensure you replace `{your-domain}.com` with your actual domain and include necessary headers like 'accept' and 'content-type'.
```shell
curl --request POST \
--url https://your-domain.com/customer \
--header 'accept: application/json' \
--header 'content-type: application/json'
```
--------------------------------
### Initialize KBMConfiguration
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/customization-brand-messenger-in-ios
Create and apply a custom configuration object to the BrandMessengerManager.
```Swift
let config = KBMConfiguration()
/// Change properties here...
/// Read below to know about different properties used in `KBMConfiguration`
BrandMessengerManager.setDefaultConfiguration(config)
```
--------------------------------
### Initialize SDK Instance
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-flutter-sdk
Create an instance of the SDK in your App class and trigger the chat interface.
```dart
class App extends StatelessWidget {
const MyApp({super.key});
static FlutterBrandmessengerSdk bmsdk = FlutterBrandmessengerSdk();
...
}
```
```dart
App.bmsdk.show();
```
--------------------------------
### Configure Radio Select items
Source: https://developer.khoros.com/khoros-flow/docs/radio-select
Examples of configuring individual items with images, subtitles, or both.
```JavaScript
const url = await webview.radioSelect.create({
...
items: [{
title: 'Cat',
image: 'https://...',
onSelect: {
eventName: 'select',
params: new Param('category', 'animal')
}
}]
...
})
```
```JavaScript
const url = await webview.radioSelect.create({
...
items: [{
title: 'Cat',
subtitle: 'meows a lot',
onSelect: {
eventName: 'select',
params: new Param('category', 'animal')
}
}]
...
})
```
```JavaScript
const url = await webview.radioSelect.create({
...
items: [{
title: 'Cat',
image: 'https://...',
subtitle: 'meows a lot',
onSelect: {
eventName: 'select',
params: new Param('category', 'animal')
}
}]
...
})
```
--------------------------------
### GET /api/public/reports/report/conversation_actions
Source: https://developer.khoros.com/khoroscaredevdocs/reference/reportsreportconversation_actions
Generates a Conversation Actions export using a GET request. While functional, POST is the recommended method for this endpoint.
```APIDOC
## GET /api/public/reports/report/conversation_actions
### Description
Generate a Conversation Actions export. This endpoint is an alternative to the POST method, but POST is recommended.
### Method
GET
### Endpoint
https://analytics-api.app.lithium.com/api/public/reports/report/conversation_actions
### Parameters
#### Query Parameters
- **businessHourType** (boolean) - Optional - Sets the business hour type. `true` means “within business hours”, `false` means “outside of business hours”, and null/missing means “No Business Hours, aka 24/7”. If `true`, `enableBusinessHour` must also be `true`.
- **companyKey** (string) - Required - The company key found in **Account Admin > General Settings > Analytics API Settings**.
- **enableBusinessHour** (boolean) - Optional - Defaults to false. Enables filtering by business hours using the `businessHourType` parameter. If `true`, `businessHourType` must be set.
- **endTime** (string) - Required - The end time in epoch milliseconds. This value will not be adjusted.
- **includeDisabled** (boolean) - Optional -
- **locale** (string) - Optional - The locale to use for the export. Supported values: en, es, fr, de, tr
- **priorities** (string) - Optional - Filters the export to only data (posts or conversations) that match the specified priority. Pass a comma-separated list with values 0 through 5. The list must be URL-encoded. For example: priorities=0%2C1%2C2%2C3%2C4%2C5. If not specified, all priorities are included.
- **reportFormat** (string) - Optional - Defaults to json. The format of the export. Possible values: json or csv.
- **reportMetrics** (string) - Optional - Use `reportMetrics` to return specific metrics (columns) in the report. Use a separate `reportMetrics` query parameter for each metric desired. Example: `reportMetrics=agent_name&reportMetrics=agent_email&reportMetrics=agent_id`.
- **smartViewId** (string) - Optional - Filters the export to only data (posts or conversations) that match the specified smart view. You must use the ID of the smart view for this parameter. Only one smart view ID can be passed in as a parameter.
- **startTime** (string) - Required - The start time in epoch milliseconds. This value will not be adjusted.
- **timezone** (string) - Optional - A time zone ID to specify in which time zone to format dates in the report export. Find supported time zone IDs using the `/config/timezones` endpoint.
- **timezoneOffset** (string) - Optional - Pass the timezone offset in milliseconds to calculate and format dates in the report to this offset. If not provided, then times will be in UTC. This is only used to format dates and is not aware of Daylight Saving Time changes.
### Response
#### Success Response (200)
- **workflowId** (string) - Unique ID for the export job.
- **runId** (string) - Unique ID for the export job run.
- **statusUrl** (string) - URL to check the status of the export job.
- **downloadUrl** (string) - URL to download the export once it is ready.
### Notes
- All fields in exports are of the datatype `String` and have a field length of `unbounded`.
- Times will be formatted per the Company setting OR the Locale that the user specifies when running the export.
- All arguments are case-sensitive.
- The `workflowId` and the `runId` in the response are used by the `/reports/report/workflowId/runId/status` and `/reports/report/workflowId/runId/download` endpoints.
- To check status, make a GET request to the `/reports/report///status` endpoint as shown in the `statusUrl` field. When the `result.runnerState` is CLOSED and `.detail` is COMPLETED, you are ready to download.
- To download, make a GET request to the `/reports/report/workflowId/runId/download` endpoint as shown in the `downloadUrl` field.
- See Using timezone with timezoneOffset when making a request with these parameters.
- See Define columns to return in an export to learn how to specify a limited set of columns to return in the export.
```
--------------------------------
### Bot API v3 Request Response Example
Source: https://developer.khoros.com/khoroscaredevdocs/docs/monitor-requests-to-the-bot-api-3
Example of the JSON response structure returned when querying Bot API v3 requests.
```json
{
"data": {
"id": "03a913a3-552e-4e2a-8d23-d1e5257474bc",
"companyKey": "mycompany",
"externalId": "9876543211234567",
"networkKey": "facebook",
"appId": "company-bot",
"callbackUrl": "https://www.example.com/receive",
"origin": "BOT",
"state": "PENDING",
"payload": ,
"createdEpochMillis": 1551757370603,
"completedEpochMillis": 1551757370707,
"lastUpdatedEpochMillis": 1551757370707
}
}
```
--------------------------------
### Create a Terms Webview
Source: https://developer.khoros.com/khoros-flow/docs/terms
Initializes a new terms webview with a specified reference, confirmation event, and Markdown-formatted content.
```javascript
const url = await webview.terms.create({
ref: 'terms',
onSelect: {
eventName: 'ACCEPTED'
},
title: 'Accept our terms of usage',
tint: '#000',
content: `
# Title
A simple paragraph with text
## Heading 2
- List item 1
- List item 2
- List item 3
`
})
```
--------------------------------
### Configure Base and Auth Handler URLs
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/authentication-and-authorization-in-ios
Set the base and authentication handler URLs before initializing the SDK. These URLs are region-specific.
```Swift
KBMUserDefaultsHandler.setBASEURL("your-base-url")
KBMUserDefaultsHandler.setCustomAuthHandlerUrl("your-auth-handler")
```
```Objective-C
[KBMUserDefaultsHandler setBASEURL:@"your-base-url"];
[KBMUserDefaultsHandler setCustomAuthHandlerUrl:@"your-auth-handler-url"];
```
--------------------------------
### Message Event Payload Example
Source: https://developer.khoros.com/khoroscaredevdocs/reference/incoming-message-payloads-channel-to-bot
An example of a JSON payload representing a standard message event. This payload is received when an author sends a message to the bot.
```json
{
"coordinate":{
"companyKey":"...",
"networkKey":"whatsapp",
"externalId":"5de...",
"messageId":"5e2...",
"botId":"bot-id",
"scope":"PRIVATE",
"normalizedAuthorId":"3a4..."
},
"text":"hello",
"author":{
"id":"3a4...",
"fullName":"Jo",
"properties":{
}
},
"owner":{
"type":"AGENT"
},
"publishedTS":1579793945986,
"receivedTS":1579793946280,
"properties":{
},
"type":"message"
}
```
--------------------------------
### Initiate Chat with Welcome Message (Java)
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-android-sdk-conversation
If welcome messages are configured, this method initiates the chat and sends an API request for a welcome message.
```java
BrandMessengerManager.showWithWelcome(context);
```
--------------------------------
### Install SDK via pubspec.yaml
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-flutter-sdk
Add the SDK dependency to your project's pubspec.yaml file.
```yaml
flutter_brandmessenger_sdk:
git:
url: git@github.com:lithiumtech/flutter_brandmessenger_sdk.git
ref: main
```
--------------------------------
### GET /v2/analytics/surveys
Source: https://developer.khoros.com/khorosmarketingdevdocs/reference/surveys-list-all-survey-data-for-a-set-of-streams
Returns a list of available survey data for a given set of streams. Use the streams endpoint to get the appropriate stream IDs.
```APIDOC
## GET /v2/analytics/surveys
### Description
Returns a list of the available survey data for a given set of streams.
### Method
GET
### Endpoint
https://api.spredfast.com/v2/analytics/surveys
### Query Parameters
- **start** (string) - Optional - Start date in ISO-8610 format (YYYY-MM-DDTHH:MM:SSZ). Defaults to 2016-01-01T00:00:00Z.
- **stop** (string) - Optional - End date in ISO-8610 format (YYYY-MM-DDTHH:MM:SSZ). Defaults to 2017-05-01T00:00:00Z.
- **stream_ids** (array of int32s) - Optional - A list of stream IDs to report on, one value per line (e.g. no delimiter), defaulting to all streams.
### Headers
- **accept** (string) - Optional - Defaults to application/json. Allowed values: `application/json`, `text/plain`.
### Responses
#### Success Response (200)
- **Result** (object) - Contains the survey data.
#### Error Response (403)
- **Result** (object) - Indicates an authorization error.
### Request Example
```json
{
"example": "curl --request GET --url 'https://api.spredfast.com/v2/analytics/surveys?start=2016-01-01T00%3A00%3A00Z&stop=2017-05-01T00%3A00%3A00Z' --header 'accept: application/json'"
}
```
### Response Example
```json
{
"example": "{\"data\": [ { \"surveyId\": \"survey_123\", \"streamId\": \"stream_abc\", \"completionRate\": 0.75 } ] }"
}
```
```
--------------------------------
### Link iOS Pod
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/install-brand-messenger-react-native-sdk
Navigate to the iOS directory and run 'pod install' to link the iOS pod project.
```bash
cd ios
pod install
```
--------------------------------
### Typing Start Indicator Payload
Source: https://developer.khoros.com/khoroscaredevdocs/reference/respond-post
Send this JSON payload to indicate that the bot has started typing a response. Requires author, coordinate, and type fields.
```json
{
"author":{
"id":"adf9as8df9sfi",
"fullName":"fullname"
},
"coordinate":{
"companyKey":"company",
"networkKey":"smooch",
"externalId":"sf8u123jfasdf123",
"botId":"botId",
"scope":"PRIVATE"
},
"type":"typing_start"
}
```
--------------------------------
### Create an Article Webview with Markdown
Source: https://developer.khoros.com/khoros-flow/docs/article
Initializes an article webview using Markdown syntax within the content property for formatted text.
```javascript
const url = await webview.article.create({
ref: 'article',
title: 'Hello world',
content: `
# Title
A simple paragraph with text
## Heading 2
- List item 1
- List item 2
- List item 3
`
})
```
--------------------------------
### Closed Conversation Event Payload Example
Source: https://developer.khoros.com/khoroscaredevdocs/reference/incoming-message-payloads-channel-to-bot
An example of a JSON payload for a 'update' type event, specifically indicating a conversation has been closed. This is used to signal the end of an interaction.
```json
{
"coordinate":{
"companyKey":"...",
"networkKey":"apple",
"externalId":"5bb...",
"botId":"ABCBot",
"scope":"PRIVATE",
"normalizedAuthorId":"urn:mbid:AQ..."
},
"author":{
"id":"urn:mbid:AQ...",
"fullName":"Anonymous Stork 1afc-9b12"
},
"operation":"CLOSED",
"conversation":{
"displayId":5178076,
"dispositionId":19,
"encodedDispositionId": 320,
"conversationUuid": "3de...."
},
"type":"update"
}
```
--------------------------------
### Example API Request for Team Performance
Source: https://developer.khoros.com/khoroscaredevdocs/reference/reportsreportteam_performance_interval
This example demonstrates how to request team performance metrics with specific time intervals and team IDs. Ensure to replace placeholders like [USERNAME], [PASSWORD], and [COMPANY_KEY] with your actual credentials and company key. The `timeInterval` parameter dictates the granularity of the report.
```Shell
curl -u [USERNAME]:[PASSWORD] -XPOST \
'https://analytics-api.app.lithium.com/api/public/reports/report/team_performance_interval?companyKey=[COMPANY_KEY]&startTime=1548979200000&endTime=1556668800000&timezoneOffset=-21600000&enableBusinessHour=true&locale=en&teamIds=175%2C154%2C151%2C128%2C42%2C155%2C210%2C71%2C15%2C63%2C192%2C32%2C153%2C69%2C65&timeInterval=86400000&includeDisabled=true'
```
--------------------------------
### Example Secure Transfer URL with Payload
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/secure-transfer-1
This is an example of a shortened transfer link used in Secure Transfer. The link includes an encrypted payload containing conversation details.
```text
https://[Link-to-Portal]?payload=QReebTFORdgX..&iv=kAO...
```
--------------------------------
### Get CustomChannel by ID - cURL Request
Source: https://developer.khoros.com/khorosmarketingdevdocs/reference/get-a-customchannel-based-on-id
Use this cURL command to make a GET request to retrieve a custom channel. Ensure you replace 'customChannelId' with the actual ID.
```Shell
curl --request GET \
--url https://api.spredfast.com/v2/conversations/calendar/customChannel/customChannelId \
--header 'accept: application/json' \
--header 'content-type: application/json'
```
--------------------------------
### Date Picker Creation
Source: https://developer.khoros.com/khoros-flow/docs/date-picker
This snippet demonstrates how to create a Date Picker instance with essential configurations.
```APIDOC
## POST /webview/datePicker/create
### Description
Creates a Date Picker instance within the webview.
### Method
POST
### Endpoint
/webview/datePicker/create
### Parameters
#### Request Body
- **ref** (string) - Optional - If provided, the webview will update its content.
- **title** (string) - Required - The title shown at the top of the webview.
- **tint** (string) - Optional - The tint color applied to the buttons.
- **button.label** (string) - Optional - The text displayed on the confirmation button.
- **onSelect.eventName** (string) - Required - The name of the event that will be triggered when a selection is made.
- **onSelect.paramName** (string) - Optional - The name of the parameter that will hold the selected date.
### Request Example
```json
{
"ref": "pickup-date",
"title": "Choose a pick up date",
"onSelect": {
"eventName": "pick date",
"paramName": "date"
}
}
```
### Response
#### Success Response (200)
- **url** (string) - The URL to be loaded in the webview.
#### Response Example
```json
{
"url": "https://example.com/datepicker"
}
```
```
--------------------------------
### Example Actions Object
Source: https://developer.khoros.com/khoroscaredevdocs/reference/actions-object
This object is used when your bot responds with a postback or reply payload. Ensure all required fields are present.
```json
"actions":[
{
"type":"postback",
"payload":"DEVELOPER_DEFINED_PAYLOAD-001",
"text":"A good way to keep h..."
}
]
```
--------------------------------
### AppDelegate Setup for BrandMessengerManager
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/notifications-brandmessenger-ios-sdk
This code is mandatory for BrandMessengerManager integration. Include it in your AppDelegate file, especially if using custom push notification setups like Firebase or OneSignal.
```objective-c
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ... other setup code
[BrandMessengerManager didFinishLaunchingWithOptions:launchOptions];
// ... other setup code
return YES;
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(nonnull UNNotificationResponse* )response
withCompletionHandler:(nonnull void (^)(void))completionHandler {
[BrandMessengerManager userNotificationCenter:center didReceive:response withCompletionHandler:^{
// Process your own notification here.
completionHandler();
}];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
[BrandMessengerManager applicationWillEnterForeground:application];
}
- (void)applicationWillTerminate:(UIApplication *)application {
[BrandMessengerManager applicationWillTerminateWithApplication:application];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[BrandMessengerManager application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
```
--------------------------------
### Initiate Chat with Welcome Message
Source: https://developer.khoros.com/khorosbrandmessengerdocs/docs/brand-messenger-react-native-sdk-conversation
Launches the chat screen and triggers a welcome message API request if configured in the Care instance.
```TypeScript
BrandmessengerSdk.showWithWelcome((error: null | string, success: null | string) => {
if (error !== null) {
// Show chat screen error
} else {
// Show chat screen success
}
});
```
--------------------------------
### Created Conversation Event Payload Example
Source: https://developer.khoros.com/khoroscaredevdocs/reference/incoming-message-payloads-channel-to-bot
An example of a JSON payload for a 'update' type event, indicating that a new conversation has been created. This payload is sent when a new interaction begins.
```json
{
"coordinate":{
"companyKey":"...",
"networkKey":"whatsapp",
"externalId":"5de...",
"messageId":"5e2...",
"botId":"5a3...",
"scope":"PRIVATE",
"normalizedAuthorId":"05..."
},
"author":{
"id":"05...",
"fullName":"name"
},
"operation":"CREATED",
"conversation":{
"displayId":123,
"dispositionId":0,
"encodedDispositionId": 0,
"conversationUuid": "3de...."
},
"type":"update"
}
```
--------------------------------
### Initialize Khoros React App
Source: https://developer.khoros.com/khoros-flow/changelog/khoros-flow-release-notes-october-22-2021
Initializes the Khoros React application and sets up event listeners for component readiness. This code should be run once during application startup.
```javascript
window.ioradNodeApp = window.ioradNodeApp || {}; window.ioradNodeApp.reactComponent = null; window.ioradNodeApp.reactComponent = (function() { return { backboneCapturedMediaProcessingMessage: function(value) { window.ioradNodeApp.onceReactReady(function() { window.ioradNodeApp.reactComponent.backboneCapturedMediaProcessingMessage(value); }); }, onTutorialsPageDataChanged: function() { window.ioradNodeApp.onceReactReady(function() { window.ioradNodeApp.reactComponent.onTutorialsPageDataChanged(); }); }, getVoices: function(...args) { return new Promise(function(resolve, reject) { window.ioradNodeApp.onceReactReady(function() { window.ioradNodeApp.reactComponent.props.getVoices(...args) .then(resolve, reject); }); }); }, generateSpeech: function(...args) { return new Promise(function(resolve, reject) { window.ioradNodeApp.onceReactReady(function() { window.ioradNodeApp.reactComponent.props.generateSpeech(...args) .then(resolve, reject); }); }); }, callComponentFunction: function() { var args = Array.prototype.slice.call(arguments); var propName = args[0]; var functionArgs = args.slice(1); return new Promise(function (resolve, reject) { window.ioradNodeApp.onceReactReady(function () { Promise.resolve() .then(function () { return window.ioradNodeApp.reactComponent[propName].apply( window.ioradNodeApp.reactComponent, functionArgs ); }).then(resolve, reject); }); }); }, }, onceReactReadyListeners: [], onceReactReady: function(callback) { if (window.ioradNodeApp.reactComponent) callback(); else window.ioradNodeApp.onceReactReadyListeners.push(callback); }, reactComponentReady: function(reactComponent) { window.ioradNodeApp.reactComponent = reactComponent; window.ioradNodeApp.onceReactReadyListeners.forEach(function(callback) { callback(); }); window.ioradNodeApp.onceReactReadyListeners = []; } }; window.ioradNodeApp.updateIframeOnLoad(); }());
```