Sample Channel

To help get you started with the Channels API, this walkthrough should act as a valuable sample to kick off your development. We also have a Postman collection available here to help. If you have any additional questions, please reach out to us at [email protected].

Set up

  1. Fill out the form for your sample channel. Because it's for a sample channel, your answers don't need to be too in-depth. Here are our suggestions for the sample channel.
FieldYour Answer
Company NameYour company's name.
Contact NameYour name.
Contact EmailYour email.
Name of channelSample Channel.
Webhook URLOur mock server we've set up for you: https://60148d1b-b353-4438-9b63-7cd8b0f9f21c.mock.pstmn.io
Description of ChannelThis is a sample channel.
ComposeCheck this.
ReplyCheck this.
Channel Contact TypeChoose whichever.
AttachmentsCheck this.
Attachment TypesChoose whichever.
Icon for your channelLeave empty. It's an optional field.
Auth MethodAPI Token. For the sample, you can fake a token with any string. The token won't be verified in the sample channel.
OAuth fieldsLeave blank
  1. Front will create a new Channel Type for you. A Channel Type is an entity that represents the configuration you sent to Front in the previous step. When users create a new Channel, they are creating an instance of your Channel Type.

  2. Once you have received your Channel Type's API key and Channel Type ID, keep them safe. You'll need them to make requests to Front's API.

  3. In the Postman collection provided, input your Channel Type API Key (secretKey) and Channel Type ID (channelTypeId) as environment variables.

The channelId will be added later, when we create a channel (an instance of your Channel Type).

1441
  1. In Front, add your new channel. (Settings > Inboxes > Add a team inbox)
  • For the API Key, feel free to put anything as this is just a sample channel.
  • In production, you will be responsible for:
    • Validating the request is from Front
    • Validating the API Token belongs to your system.
  1. When the new channel is added, Front sends a request to the callback URL of your Channel Type, with the authentication payload shown in the Postman collection.
  • In the channel settings Page, get the channel instance's ID (cha_XYZ). Add this channel ID to your Postman environment (channelId).
613
  • In production, you should maintain a mapping of which of your users are using which channel ID (do this by matching your system's API token to a the Front Channel ID). Look at the response of the mock server. Your callback server should return the same payload.

Sending messages

  1. Use the inbound_messages endpoint to send a message to Front. Observe that the endpoint generated depends on the channel ID.
1627
  • In the Postman collection, observe the payload. See the pre-request script to understand how we generate the API Key.
  • Note the external_conversations_id. Front threads messages on the external_conversation_id. Front will thread messages with the same external conversation ID.
  • Observe the response from Front. Front returns a message_uid.
  1. Respond to the message in Front - The request body sent to your callback server will match the example request body in the Postman collection.
782
  • Front requires your callback server to respond with a type, external_id, external_conversation_id. These IDs should reflect the message created in your system.
534
  1. Import a message using the outbound_message endpoint
672
  • Observe in Front that it is "sent" by the channel. Since we're using the same external_conversation_id, this message threads with the message in Step 1.
1209
  • Represents a message that was sent in your application that should be synced to Front.

General notes

  • Notice the webhook_url is optional, but Front strongly recommends generating a unique webhook URL for each channel.
  • Front threads messages by the external_conversation_id
  • The payloads returned by your callbacks server should have the same keys as the Postman collection.