Skip to content
Customer messages

Flutter SDK

Open customer messages in Flutter

Present the packaged messenger, open contextual conversations, and create feedback threads from host-owned Flutter UI.

Enable customer messages

Include BtxFeature.messenger, identify the customer, and mount BtxHost or provide a root navigator key. The default feature set already includes the messenger.

App startup
await Btx.configure(
  BtxConfiguration(
    publishableClientKey: 'cfk_...',
    features: const <BtxFeature>{BtxFeature.messenger},
  ),
);

await Btx.identify(
  const BtxCustomer(externalId: 'customer_123'),
);
01

Present from your interface

Connect a Help, Support, or Messages control to the facade.

Button action
await Btx.messenger.present();

The packaged messenger shows conversation history, creates new threads, sends images, renders message links as tappable URLs, and offers long-press text copy. Use Btx.messenger.dismiss() when the host needs to close it programmatically.

02

Open a contextual conversation

Use presentCompose(...) when the customer starts from a specific product surface. A launch context can carry a purpose, entry point, source object, thread title, low-cardinality attributes, and optional intro content.

Order support
await Btx.messenger.presentCompose(
  BtxLaunchContext(
    conversationPurpose: BtxConversationPurpose.support,
    entryPoint: 'order_detail',
    sourceType: 'order',
    sourceId: order.id,
    threadTitle: 'Order support',
    attributes: <String, String>{
      'orderStatus': order.status,
    },
  ),
);
  • Use stable entry point and source type names.
  • Include source IDs only when they are safe and useful to the support team.
  • Use presentThread(threadId) to reopen a known BTX conversation.
  • Keep thread titles short enough to scan in customer and operator views.
03

Create a thread without opening the messenger

Host-owned feedback forms can create a replyable customer message thread directly. Use the feedback purpose so operator surfaces can label and prioritize it separately from a support request.

Host feedback form
final thread = await Btx.messenger.createThread(
  subject: 'App feedback',
  body: feedbackText,
  launchContext: const BtxLaunchContext(
    conversationPurpose: BtxConversationPurpose.feedback,
    entryPoint: 'feedback',
    sourceType: 'host_feedback_form',
  ),
);

Pass present: true when the host should create the thread and immediately open it. createThread(...) also accepts prepared BtxImageInput attachments.

04

Understand foreground delivery

With realtime enabled, the facade starts one foreground connection after identity is established, even before the messenger opens. It pauses in the background, reconciles when the app resumes, and keeps conversation state current without periodic hidden polling.

  • Keep autoStart and enableRealtime enabled for the normal integration.
  • Foreground replies can show an SDK-owned in-app banner while the messenger is hidden.
  • Background reply alerts require platform push setup.
  • Sign-out, customer replacement, and SDK disposal stop the previous customer's realtime work.