Skip to main content
Plains API first infrastructure means that you never need to wait for an official integration to bring all of your customer channels and communications into your Support platform.
Custom channels in Plain
Until we launch an official integration for a channel that you need. You can start bringing your customer messages in using custom middleware that accepts webhooks and makes POST requests.

Creating customers

For every message to reach Plain, your middleware needs to create a customer when none exists, and match the existing one when it does. Plains customer object requires an email address.
  • Find out what identifiers are passed from your custom channel message received events
  • Map relevant identifiers to Plain
  • Make sure that the middleware tries to match existing customers first, and creates them as a fallback instead of by default.

Sending messages

  1. Messages created in Plain trigger a webhook
  2. Your middleware accepts that webhook
  3. Parse the required information out of it (message body, customerId, etc.)
  4. Then make a request to send that message into your new channel of choice

Receiving messages

Accepting messages from your custom channel and writing them into Plain works the exact same way, but in reverse.
  • You’ll need to accept messages from your custom channel, which is also done via webhooks (for example, with Whatsapp)
  • Then your middleware will need to parse that message and use the Plain GraphQL API to create a new thread or create a new message in an existing thread.

Attributing Messages

When your middleware writes a reply into an existing thread, by default the message is authored by the Machine User named when creating the API key. If you want messages to appear as being from a member of your team, or a customer you can pass impersonation on Reply to Thread.
  • To author the message as the customer, set asCustomer and pass one identifier on customerIdentifier: emailAddress, customerId, or externalId. The message shows up in Plain as if that customer sent it. This also needs the customer:impersonate permission.
  • To write the message as a member of your team, set asUser and pass userId or emailAddress on userIdentifier. The customer will see your team members name. You can’t impersonate a machine user. The API key has to be allowed to reply as that user: add the user and their role to the key’s impersonation allow list.

Matching messages from your custom channel to Plain threads

If your customers start conversations from your custom channel, you’ll need to make sure that you’re passing the custom channels customer identifier as a Customer externalID when upserting the customer. Which will need to be done before creating the thread. This is the customer’s identifier in the channel, like their WhatsApp userId. For example, if you identify customers in a channel like Whatsapp by their phone number. You would upsert the Customer with their phone number as their ExternalID, then create the thread in Plain passing in that external ID.

Considerations

  • Custom channels will not look like 1st party channels and do not come with all the native features of first party channels like Email or Slack.
  • To attribute a reply to a customer or a member of your team, use replyToThread with impersonation. sendCustomerChat writes a customer message without impersonation, and sendChat writes as the machine user. See Attributing messages you write into Plain.
  • If you don’t have a way of pairing a customer with their real email address on creation, you need to add a temporary email address. Such as: channelidentifier@temp-yourcompany.com. If this is the case, use sendChat for replies instead of replyToThread.
  • Custom channel threads appear under the “API” channel in the “channel” selector across the app, and in filters (Custom views, Insights.etc).
  • You can’t set custom icons. So if you built a Whatsapp integration you wouldn’t be able to set a logo, or have a Whatsapp entry listed in any channel filtering and dropdowns.
  • Use a label to always tag your custom channel’s threads when they’re created by your Middleware. That way you can filter / sort / report on your custom channel threads via that Label.

Examples:

Discourse

With Plain you can connect your Discourse community and automatically keep track of threads via Plain. This works by deploying a small node service which uses Plain and Discourse’s APIs. You can either self-host this little node service or we can deploy this for you. Check out the example on Github → This integration can be customized depending on the structure of your Discourse community and ideal support workflow. For example you could customize the priority, labels and assignee of threads from Discourse based on their category, author and content.

Hubspot

This is now handled by the first-party HubSpot integration. It’s provided here only as an architecture example This integration automatically creates Hubspot tickets when threads are created in Plain.
  1. Receives thread.thread_created webhook from Plain
  2. Fetches thread details to get account ID
  3. Fetches account details to get HubSpot company ID (externalId)
  4. Creates HubSpot ticket associated with the company
  5. Automatically refreshes HubSpot token if expired
Check out the example on Github →