Messenger, inbox and help screens
The package has ready-made screens for the messenger, the user’s tickets, the help center and their preferences. They follow your theme (Theming) and each platform’s look.
Routes
Section titled “Routes”The pages live at their own paths. These are also the links PurrCRM writes, in a reply, a push or an article, so they must not clash with your own:
| Path | Page |
|---|---|
/messages | The messenger’s home |
/messages/new | A new conversation |
/messages/<id> | A conversation |
/messages/tickets, /messages/tickets/<id> | The tickets, a ticket |
/help | The help center |
/help/collections/<slug> | A collection |
/help/<slug> | An article |
/messages/show/<id> | An in-app message whose link opens it, shown over the page |
/messages/preferences | The user’s preferences |
With go_router, mount crmGoRoutes(fallback: '/your/help/page') and hand the facade GoRouterCrmNavigator(router) (Initialise). A page whose part is switched off, or anyone signed out, goes to fallback.
With a plain Navigator, hand the facade NavigatorCrmNavigator(navigatorKey). Each page is pushed over yours.
As widgets, route to them as you like: CrmMessengerScreen, CrmConversationScreen, CrmTickets, CrmTicketScreen, CrmHelpCenter, CrmCollection, CrmArticleScreen, CrmPreferencesScreen. They find the facade through the CrmScope above them.
From code, crm.open(destination) puts a page in place, as a tapped push does, and crm.show(destination) pushes it over the current one.
Opening the messenger
Section titled “Opening the messenger”Put the unread count on whatever opens the messenger:
CrmUnreadBuilder( builder: (context, unread) => Badge( isLabelVisible: unread > 0, label: Text('$unread'), child: IconButton( icon: const Icon(Icons.chat_bubble_outline), onPressed: () => context.push('/messages'), ), ),)For a settings page that looks like the package’s own, use its rows: CrmRowGroup, CrmRow, CrmRowIcon and CrmCountBadge.
Which parts a user has
Section titled “Which parts a user has”The messenger, the help center and in-app messages are switched on for the app on PurrCRM (Settings › your app › General), and the package reads them as it starts. crm.appFeatures is the parts the app has on, as a listenable for your own ways in, such as a tab. crm.features is the parts the user signed in has.
To hold a part back from some users (behind a feature flag of your own), name the parts they may have in CrmSession.features: they get the parts the app has on and you name. Naming a part never switches on one the app has off.
The messenger’s home
Section titled “The messenger’s home”Your team designs the home on Settings › Channels › Messenger: a greeting with the user’s name, the team’s faces and reply time, and cards such as “Send us a message”, their open conversations, their tickets and featured articles (Set up the inbox and help center). CrmMessengerScreen draws it. Until your team publishes one, it draws its own home.
If a help bot is set up, it speaks first when the user taps Send us a message, before anything is sent: no empty conversation reaches your inbox if they leave.
Pictures
Section titled “Pictures”To let users send pictures, hand the facade your picker. With image_picker:
crm.host = crm.host.copyWith( pickPictures: (most) async { final files = await ImagePicker().pickMultiImage(limit: most); return <CrmPicture>[ for (final f in files) (bytes: await f.readAsBytes(), name: f.name, type: pictureTypeOf(f.name)), ]; },);Without it, the messenger has no add-picture button. Your team can also turn pictures off for everyone.
A test phone tile
Section titled “A test phone tile”CrmTestPhoneTile() shows “Check for tests now” to a user your team made a test phone, and nothing to anyone else. Put it on your settings page.