@statflo/textkit-widget-events
v1.3.3
Published
TextKit Events for Widgets
Downloads
8
Keywords
Readme
TextKit Widget Events
This package defines all the available events within the TextKit platform this package extends the Widget SDK package. We export all the functionality from that package along with our implementation of it.
We also include the necessary iframeResizer.contentWindow.min.js
file needed for external widgets. This will always be included therefore it's not necessary to include or import.
Installation
yarn add @statflo/textkit-widget-events
More Documentation
For more information on widget communication or container intialization you can refer to our Widget SDK Readme
Container Initialization
This function will create the initial Widget State.
Usage
import { createWidgetState, ContainerClient } from '@statflo/textkit-widget-events'
// Initialize Container
const containerClient = new ContainerClient({ window });
// Set the widgets unique id
const id = 'widgetId';
// Initialize widget inside client with default state
containerClient.createWidget(createWidgetState(id));
Widget Initialization
import { WidgetClient } from "@statflo/widget-sdk";
export const client = new WidgetClient({
id: "my widget",
window,
createWidgetState: (id) => ({ id }),
});
Events
Usage
import { EventNames } from '@statflo/textkit-widget-events'
Widget Properties
EventNames.widget.postForwardExample
: This event will forward the event data to other widgets this is for cross widget communication.
EventNames.widget.actionCreationFailed
: This event will alert of error when actions are created.
EventNames.widget.appendTextToMessage
: This event will append text to the message box.
EventNames.widget.replaceTextMessage
: This event will replace the contents of the message box.
Container Events
EventNames.container.activeConversationChanged
: This event will include context data when a conversation changes within TextKit so you can know with whom you are speaking to.
EventNames.container.appContextChanged
: This event will include context data about the app session.
Widget Types
Usage
import { WidgetTypes } from '@statflo/textkit-widget-events'
Enum values
- Standard
- Action
- Timeline
- Sendable
Widget Scopes
Usage
import { WidgetScope } from '@statflo/textkit-widget-events'
Enum values
- User
- Conversation
Widget Tabs
Usage
import { WidgetTabs } from '@statflo/textkit-widget-events';
Enum values
- Widget
- Timeline
Widget State
Usage
import { WidgetState } from '@statflo/textkit-widget-events'
Enum values
- containerDomain
- footer
- header
- id
- isOpen
- isReady
- isShown
- label
- maxHeight
- size
- type
- url
- widgetDomain
Widget View Sizes
Usage
import { WidgetViewSize } from '@statflo/textkit-widget-events'
Enum values
- Large
- Medium
- Small
Debug Log
Usage
import { DebugLogLevel } from '@statflo/textkit-widget-events'
Enm values
- None
- Debug
Example
import { DebugLogLevel, ContainerClient } from '@statflo/textkit-widget-events';
export const widgetContainerClient = new ContainerClient({
logs: DebugLogLevel.None,
window,
});