mysampark_chat 1.2.2
mysampark_chat: ^1.2.2 copied to clipboard
Official MySampark Chat Widget for Flutter. Add AI-powered live chat with human agent takeover, typing indicators, lead forms, and real-time WebSocket support.
1.2.2 #
- Added a "Select" button to product cards, shown when the backend sends
select_products: trueon a reply (only for widgets that have a booking-style action/sequence which actually uses the id it sends back — a plain Q&A bot's cards are unaffected). Tapping it sends [ProductCard.id] back asselected_product_idon the next message, so the backend settles which item the conversation is about exactly, instead of guessing it back from the product name as plain text. Distinct from the existing "View product" button, which still opens the product itself (in-app viaonProductTap, or the browser). ChatService.sendMessage()takes an optionalselectedProductIdparameter, sent asselected_product_id.- Added
MessagePayload.selectProducts, parsed fromselect_products. Requires a backend that sends it; older backends simply leave it false and no Select button renders.
1.2.1 #
- Added
ProductCard.features— vendor/sku/barcode/attributes as synced from Shopify/WooCommerce/the push API. Null for a manually-entered product or one with no synced attributes. Requires a backend that sendsfeaturesonproducts_referencedcards; older backends simply leave it null. - Added
ProductCard.raw— the card exactly as the backend sent it, so a host app can read a field this class doesn't model yet without waiting on a package update.
1.2.0 #
- Added
onProductTaptoMySamparkChatScreenandMySamparkChatBubble— a product card can now open inside the host app instead of throwing the visitor out to a browser. Returntruefrom the callback and the package does nothing further; returnfalse, or leave it unset, and the card's URL opens exactly as before, so an app only writes code for the products it actually stocks. TheBuildContextpassed in is the chat's own, which is what pops the bubble's bottom sheet — the host app's context can't, and pushing from it leaves the product page hidden behind the sheet. - Added
ProductCard.externalIdandProductCard.source— the merchant's own id for the product and which catalogue it came from (api,shopify,woocommerce).ProductCard.idhas always been MySampark's internal id, which a host app can't match against its own catalogue;externalIdis the one to look up. Null for products the merchant typed in by hand, and for cards restored from conversations that predate this release, both of which fall back to the browser on their own. - A product card with no URL is now tappable when
onProductTapis set, so an app-only listing can still open — previously the whole card and its button were hidden without a link. - Requires a backend that sends
external_product_idonproducts_referenced. Older backends simply leave it null. - Fixed: every non-INR price rendered with a bare
$.ProductCard.formattedPricehad one branch —₹for INR,$for everything else — so a Singapore merchant's SGD 48 card read as US dollars, and so did AUD, CAD, HKD and NZD. Prices now carry their regional prefix (S$,A$,C$,NZ$,HK$,NT$,R$,MX$), the major non-dollar symbols are listed too, and an unlisted currency falls back to its ISO code (MYR 48) rather than guessing.intl'sNumberFormat.simpleCurrencyis not used for this — its own table maps SGD, AUD, CAD, HKD and NZD all to a bare$. - Fixed: the header ignored the merchant's support hours.
support_onlinehas always arrived oninit()and been parsed intoWidgetConfig.supportOnline, but nothing read it — the status dot reflected only whether the WebSocket was connected. A merchant who marked Sundays closed saw "Offline" on their own website widget and "Online" here. The status now combines both, exactly as the web widget does. - Fixed: "talk to a human" buttons appeared outside support hours. A
confirm_escalationreply rendered its Yes/No buttons whenever it was on screen, including when replayed from history after closing time — offering the visitor a handoff nobody was there to take. They now render only while support is online.
1.1.8 #
- Fixed: product cards never rendered in chat. The backend sends
products_referencedalongside aproduct_list/product_detailreply, and the reply text is only an introduction — "Here are some products currently available: A, B, C." — so the app showed that sentence and nothing else, with no picture, price or link. Cards now render under the reply as a horizontal carousel, matching the web widget. - Fixed: offer cards never rendered in chat. Same cause, worse symptom: an
offer_listreply's text is "Here are our current offers:" and the cards were dropped, leaving a bubble that ended on a colon. In-chat offers now use the same tile as the Offers tab. (The Offers tab itself was unaffected — it loads from/offersseparately.) - Fixed: merchant-defined Track Order fields were ignored.
order_tracking_extra_fieldsarrives oninit()and the web widget renders one input per entry, sending them back underparams. This package rendered none and sent none, so a merchant whose order API requires an extra field (a postcode, a phone number) got an incomplete request and the visitor got "we couldn't find that order" for a correctly filled form. Shopify-backed order tracking was never affected — that path takes no extra parameters. - Added
ProductCardandOrderTrackingFieldmodels, and exportedMessagePayload,MessageHighlight,MessageSectionandMessageCta— all four were already reachable throughChatMessage.payloadwithout being nameable. ChatService.trackOrder()takes an optionalparamsmap.
1.1.7 #
- pub.dev score maintenance, no behavior changes:
- Added dartdoc comments across the public API (
MySamparkChatBubble,MySamparkChatScreen,ChatService, and all exported models) for the pub.dev "Provide documentation" score. - Bumped
intlto^0.20.3andflutter_lintsto^6.0.0(up-to-date dependencies score). - Fixed all analyzer lints flagged by
flutter_lints6.0.0 (withOpacity→withValues,unnecessary_library_name,curly_braces_in_flow_control_structures, string concatenation → interpolation) and applieddart format.
- Added dartdoc comments across the public API (
1.1.6 #
- Fixed:
MySamparkChatBubble's in-app notification banner could pop up on top of aMySamparkChatScreenthe visitor already had open, if that screen was opened some other way than the bubble's own_openChat()(e.g. a host app's own "Support" tab doing its ownNavigator.push) — the bubble only tracked whether it had opened the chat, with no way to know a different screen instance was already showing that exact message live. - Added
MySamparkChatScreen.isAnyScreenOpen— tracks whether any instance is currently mounted, regardless of how it was opened. The bubble now checks this alongside its own state before showing the banner or incrementing the unread badge.
1.1.5 #
- Fixed: conversation starters now render on the Home tab (a card-style list above Offers/Chat/Track, matching the web widget), instead of only as chips inside an already-empty chat view. Tapping one switches to the Chat tab and sends it immediately, going through the same pre-chat survey gate as a normal message.
- Removed the old chat-view starter chips row — the web widget never had this either; starters live on Home only.
1.1.4 #
- Guest-to-login merge: a visitor's session_id is no longer cached per-identity, so a guest who logs in mid-session keeps the same session_id and the backend now merges their guest conversation into their identified thread instead of starting a disconnected second one.
- Backend:
init(),message(), andtrackOrder()all guard this merge against a shared/reused device — a session_id match is only adopted if it isn't already a different identity's conversation, so logging out and having someone else use the same device (or a plain anonymous visitor after that) can never inherit the previous person's thread, name, or email.submitLead()got the equivalent guard against overwriting an already-identified visitor's details.
1.1.3 #
- Fixed:
is_identifiedfrom the backend now also reflects this request's own HMAC verification, not just an existing conversation's persisted flag — a first-time logged-in visitor (verified but with no conversation yet, since those are only created lazily) was incorrectly treated as anonymous, so they'd see the pre-chat survey and the order-tracking email field even though they were already identified. - Fixed:
trackOrder()now sendssession_idand the visitor's identity params (user_id/user_hash/user_name/user_email) — required by the backend's/track-orderfallback path for visitors who reach "Track your order" before ever sending a chat message. Without this, that path could never be reached (missingsession_idfailed validation first), and even once reached, an identified visitor's freshly-created conversation had no email attached, causing a dead-end "Email is required" error with no visible field to fix it.
1.1.2 #
MySamparkChatScreennow mirrors the web widget's close behaviour: if a conversation was started, its WebSocket stays open for a 5-minute grace period after the screen closes instead of disconnecting immediately (ChatService.scheduleGraceClose()). Screens with no started conversation still disconnect right away.- Redesigned the Offers card: tinted header, a highlight badge, and the description's meta facts (min order, usage limit, etc.) now render as scannable pill badges instead of stacked plain-text lines.
OfferItemgained abadgefield (e.g. "10% OFF", "FREE SHIPPING") — set by the backend from the actual discount data, not guessed from free text on the client.
1.1.1 #
ChatServiceWebSocket connection now matches the web widget's resilience pattern: capped auto-reconnect (max 5 attempts, exponential backoff up to 16s) instead of giving up permanently ononDone/onError.- Added a 25s ping keepalive while connected.
- Added a manual-close flag so an intentional
disconnectWebSocket()/dispose()doesn't trigger a reconnect attempt. - Fixes
MySamparkChatBubble's in-app notification banner going silent after the first WebSocket drop (app backgrounded, network blip, etc).
1.1.0 #
- Home tab —
MySamparkChatScreennow opens on a branded greeting screen with Offers / Chat / Track Order cards, matching the web widget's layout. - Offers card — fetches live deals/discount codes from
GET /api/chatbot/offers, tap-to-copy code. - Order tracking card — order lookup form (
POST /api/chatbot/track-order) showing status, carrier, and tracking link; skips the email prompt for HMAC-identified users. WidgetConfiggainedhomeGreetingTitle,homeGreetingSubtitle,showOffers,showOrderTracking, and now correctly readsaction_colorfrom the backend instead of always falling back toprimary_color.- New exported models:
OfferItem,OrderTrackResult. - Home / Chat bottom navigation; hidden while the pre-chat survey or an Offers/Order-Track sheet is open so it can't be used to bypass a non-skippable survey.
1.0.1 #
- Simplified documentation for cleaner Flutter integration.
1.0.0 #
- Initial release
- Full-screen chat screen (MySamparkChatScreen)
- Floating bubble launcher (MySamparkChatBubble)
- AI-powered replies with human agent takeover
- Real-time WebSocket support for live agent messages
- Pre-chat survey gate (admin controlled)
- In-chat lead form (name/email/phone)
- Conversation starters / quick-reply chips
- Typing indicator with 3-dot bounce animation
- Chat history with scroll-up pagination
- Online/Offline status display
- Logo, colors, and all settings synced from admin dashboard
- HMAC-SHA256 identity verification for logged-in users
- Session persistence via SharedPreferences