Custom Channel & Custom Agent Allocations
Custom Channel
The idea behind this custom channel is that you provide your own server to be hooked by messaging services (Telegram, Slack, WeChat, Email, SMS, etc) to send a message. The message then be passed to Qiscus Omnichannel Chat by your server to be gather in Qiscus Omnichannel Chat dashboard.
To implement this custom channel, here are some steps to follow. First, prepare your custom channel webhook server. It will depends on what service you are integrating with Qiscus Omnichannel Chat. But generally, the following scenario will go through within your custom channel.
- Your server will receive webhook from other service or your other messaging services.
- When your server receive the message, your server need to post the message to Qiscus Omnichannel Chat with the following format.
Header:
Content-Type : application/json
Qiscus-App-Id : {{appId}}
URL:
[POST] {{BaseUrl}}/{{appId}}/api/v2/custom_channel/send
You can get your {{appId}}
from App Information in your Qiscus Omnichannel Chat Setting.
Body :
a. Message Text
{
"identifier_key": "Tech Wrt",
"user_id": "techxxx.xxxxx@gmail.com",
"name": "Tech Wrt Custom",
"message": "Hi good morning",
"type": "text",
"avatar": "https://your-avatar-url"
}
b. Message with Attachment
{
"identifier_key": "Tech Wrt",
"user_id": "techxxx.xxxxx@gmail.com",
"name": "Tech Wrt Custom",
"message": "Hi good morning",
"type": "file_attachment",
"payload": {
"url": "https://scontent.fcgk30-1.fna.fbcdn.net/v/t39.30808-6/466042870_1110167991114426_4220661001516493640_n.jpg?_nc_cat=109&ccb=1-7&_nc_sid=127cfc&_nc_ohc=WSzSGXdy4bgQ7kNvgEAnpFp&_nc_zt=23&_nc_ht=scontent.fcgk30-1.fna&_nc_gid=AwzEAqomtioGYEPu39FRW6k&oh=00_AYA5bg1RslxeXQnU0GDopX0bahxxn61Cq3IPBxINSlMBwg&oe=673A3940",
"caption": "This image About AI in customer experience"
}
}
c. Message with Button
{
"identifier_key": "Tech Wrt",
"user_id": "techxxx.xxxxx@gmail.com",
"name": "Tech Wrt Custom",
"message": "Hi good morning",
"type": "buttons",
"payload": {
"text": "Please click this buttons!",
"buttons": [
{
"label": "button1",
"type": "postback",
"payload": {
"url": "http://somewhere.com/button1",
"method": "get",
"payload": null
}
},
{
"label": "button2",
"type": "link",
"payload": {
"url": "http://somewhere.com/button2?id=123"
}
}
]
}
}
d. Message Carousel
{
"identifier_key": "Tech Wrt",
"user_id": "techxxx.xxxxx@gmail.com",
"name": "Tech Wrt Custom",
"message": "Hi good morning",
"type": "carousel",
"payload": {
"cards": [
{
"image": "http://url.com/gambar.jpg",
"title": "Long Dress for Woman",
"description": "Oleh sippnshop\n96% (666 feedback)\nRp 49.000.00,-\nBUY 2 GET 1 FREE!!!",
"default_action": {
"type": "postback",
"postback_text": "Load more",
"payload": {
"url": "http://url.com/baju?id=123&track_from_chat_room=123",
"method": "get",
"payload": null
}
},
"buttons": [
{
"label": "button1",
"type": "postback",
"postback_text": "Load more",
"payload": {
"url": "http://somewhere.com/button1",
"method": "get",
"payload": null
}
},
{
"label": "button2",
"type": "link",
"payload": {
"method": "get",
"url": "http://somewhere.com/button2?id=123"
}
}
]
}
]
}
}
e. Message Custom
{
"identifier_key": "Tech Wrt",
"user_id": "techxxx.xxxxx@gmail.com",
"name": "Tech Wrt Custom",
"message": "e-commerce",
"type": "custom",
"payload": {
"type": "anytype",
"content": {
"anykey": "anydata"
}
},
"avatar": "https://your-avatar-url"
}
Other qiscus post comment payload please visit:http://documentation.qiscus.com/chat-server-api/message
Response:
{
"data": {
"agent": null,
"agent_service": null,
"room_log": {
"channel_id": 3xx4,
"extras": null,
"has_no_message": false,
"is_waiting": true,
"name": "Tech Wrt Custom",
"resolved": false,
"resolved_ts": null,
"room_badge": null,
"room_id": "2xxxxx6",
"source": "Tech Wrt",
"start_service_comment_id": "2xxxxx8",
"user_avatar_url": "https://your-avatar-url",
"user_id": "techxxx.xxxxx@gmail.com"
}
},
"status": 200
}

If you notice above, there is a required param called identifier_key
. To set it up, go to the integration page and just follow this simple steps.
- Click
Add Custom Channel
on Custom Channel Integration page, - Upload channel badge icon. Default channel badge icon is Custom Channel icon. The icon will be used to identified the source of the channel,
- Set the name for Custom Channel integration. This name will be used as identifier to differentiate different Custom Channel,
- Input Identifier Key. This key is used to match the source of request coming from your webhook. This is the required param. You can fill it with anything you want,
- Input Webhook URL. This webhook is your custom channel webhook URL,
- Confirm the integration by clicking
Connect
,
If everything goes well, whenever you send message through your custom messaging service (i.e: Telegram, Slack, etc), you will get the message in Qiscus Omnichannel Chat. And you can reply the message directly from Qiscus Omnichannel Chat.
For more explanation regarding the flow, please have a look at the following diagram.

We also provide you with an example of custom channel you can try to deploy it on your server. Please have a look at this repository.
Custom Agent Allocation
Qiscus Omnichannel Chat allocates available agents by automatically assign less busier agent to a new created chat group. However, you may want to customise this rule by making your own rule. In order to do so, you need to create a webhook that manage how your agents in Qiscus Omnichannel Chat is assigned.

To connect your webhook with Qiscus Omnichannel Chat, you just have to enable custom agent allocation feature in Settings page in Qiscus Omnichannel Chat by switching on the toggle button on the top-right of the page and provide the webhook URL in the field provided as depicted in image below. By doing so, Qiscus Omnichannel Chat will no longer enforce automatic rule in agent allocation for you. So you are free to do it your own way.

Qiscus Omnichannel Chat will hit your webhook with this payload that you could use in managing agent allocation,
{
"app_id": "oni-bgo2lummmhvzqxbt5",
"source": "qiscus",
"name": "sudah",
"email": "sudah@gmail.com",
"avatar_url": "https:\/\/somewhereonlyweknow.net\/prod\/image\/upload\/wMWsDZP6ta\/1516689726-ic_qiscus_client.png",
"extras": "{\"timezone_offset\":7}",
"is_resolved": true,
"latest_service": {
"id": 244,
"user_id": 1,
"room_log_id": 53,
"app_id": 1,
"room_id": "1905692",
"notes": null,
"resolved_at": "2019-02-04 04:49:47",
"is_resolved": true,
"created_at": "2019-02-04 04:49:47",
"updated_at": "2019-02-04 04:49:47",
"first_comment_id": "15167003",
"last_comment_id": "15167015",
"retrieved_at": "2019-02-04 04:49:47",
"first_comment_timestamp": null
},
"room_id": "1905692",
"candidate_agent": {
"id": 22,
"name": "dewi",
"email": "dewi@mail.com",
"authentication_token": "NlASwSIUnAqoTcFjYNBR",
"created_at": "2019-01-17 06:50:20",
"updated_at": "2019-01-18 10:12:59",
"sdk_email": "vsC6x_dewi@mail.com",
"sdk_key": "NZTGb",
"is_available": true,
"type": 2,
"avatar_url": "https:\/\/somewhereonlyweknow.net\/prod\/image\/upload\/D1se5xo40I\/1516941944-Screen_Shot_2018-01-26_at_11.45.20.png",
"app_id": 1,
"is_verified": false,
"notifications_room_id": "1692312",
"bubble_color": "#666666",
"qismo_key": "43Ondc",
"direct_login_token": null,
"type_as_string": "agent",
"assigned_rules": [
"fb_messaging",
"line_messaging",
"qiscus_messaging",
"wa_messaging",
"telegram_messaging"
]
}
}
In your webhook, it's up to you on how you will assign a newly connected user with your agents. What you will need to do however, is to hit our Assign agent to room id API when you do agent assignments. So for example, if you have a chat with doctor service, you may want to assign your users based on their selected doctors (agents).
Below are a couple of additional documentation and an example on how you could use custom agent allocation.
- Custom agent allocation API list document for you to get insight of what APIs you could use in your webhook. APIs that are often needed are API to get all agents and the least active agent.
- An example of how custom agent allocation has been done. You need to have Salesforce account to try this example.