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
- 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.
Field | Your Answer |
---|---|
Company Name | Your company's name. |
Contact Name | Your name. |
Contact Email | Your email. |
Name of channel | Sample Channel. |
Webhook URL | Our mock server we've set up for you: https://60148d1b-b353-4438-9b63-7cd8b0f9f21c.mock.pstmn.io |
Description of Channel | This is a sample channel. |
Compose | Check this. |
Reply | Check this. |
Channel Contact Type | Choose whichever. |
Attachments | Check this. |
Attachment Types | Choose whichever. |
Icon for your channel | Leave empty. It's an optional field. |
Auth Method | API Token. For the sample, you can fake a token with any string. The token won't be verified in the sample channel. |
OAuth fields | Leave blank |
-
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.
-
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.
-
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).
- 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.
- 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
).
- 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
- Use the
inbound_messages
endpoint to send a message to Front. Observe that the endpoint generated depends on the channel ID.
- 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 theexternal_conversation_id
. Front will thread messages with the same external conversation ID. - Observe the response from Front. Front returns a
message_uid
.
- Respond to the message in Front - The request body sent to your callback server will match the example request body in the Postman collection.
- 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.
- Import a message using the
outbound_message
endpoint
- 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.
- 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.
Updated over 3 years ago