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, CrmNewTicketScreen, 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 (the Name and features card on 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 › your app › 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.
Your team can let users send files beside pictures: PDF, text, CSV, ZIP, Word, Excel and PowerPoint, up to 20 MB each, and four pictures and files to a message. They turn it on in the messenger’s Options (Let contacts send files).
The package adds no file-picking plugin of its own. To offer files, hand the facade your picker as pickFiles. It is called with the most files there is room for, and answers each as CrmFile: bytes, name and type. With file_picker:
crm.host = crm.host.copyWith( pickFiles: (most) async { final picked = await FilePicker.platform.pickFiles( allowMultiple: most > 1, withData: true, type: FileType.custom, allowedExtensions: const ['pdf', 'txt', 'csv', 'zip', 'docx', 'xlsx', 'pptx'], ); return <CrmFile>[ for (final f in picked?.files.take(most) ?? const <PlatformFile>[]) if (f.bytes != null) (bytes: f.bytes!, name: f.name, type: ''), ]; },);An empty type is fine: the package works it out from the file’s name. The composer shows Add a file only when pickFiles is set and your team has turned files on. The package checks each file before it uploads it, and says in plain words why one can’t go.
In a message, each file is a row with its name and size. Tapping it opens it through your openExternal hook, which PurrCRM answers with a download. Hand the address to the browser or the system, never to a web view inside your app.
Typing and Seen
Section titled “Typing and Seen”There is nothing to set up. In a conversation, the user sees:
- the teammate’s face and three dots at the end of the conversation while they write a reply. The dots stand still when the phone is set to reduce motion;
- Seen under their last message once your team has read it, until a reply follows.
New tickets
Section titled “New tickets”When your team lets users open tickets of a type themselves (Let contacts open tickets themselves), CrmTickets shows a New ticket button. It opens CrmNewTicketScreen: a choice of forms when there are several, then the form. Once sent, the new ticket’s page takes its place. With no forms, there is no button.
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.