This API will accept the request from agent and will initiate a chat session with the agent. This is a special case where agent trigger a message to the website visitor from Agent Panel.
Resource URL
https://Server Node Environment/index.php
Example : https://api.yourdomain.com/index.php
Request
GET Params
Parameters |
Mandatory |
Description |
[Request parameters] |
|
|
d |
REQUIRED |
visitors - Controller directory name |
c |
REQUIRED |
chat - Controller name |
m |
REQUIRED |
connect_operator - Controller method name |
Headers
Parameters |
Mandatory |
Description |
Accesstoken |
REQUIRED |
Access Token |
POST Params
Parameters |
Mandatory |
Description |
[Request parameters] |
|
|
page_title |
REQUIRED |
Site page title where chatbox is showing |
page_url |
REQUIRED |
Site page URL where chatbox is showing |
sort_order |
REQUIRED |
Time in milliseconds based on Server Time |
id |
REQUIRED |
temp visitor ID |
name |
REQUIRED |
temp visitor name |
email |
REQUIRED |
temp visitor email address |
message |
REQUIRED |
temp visitor message |
operator_id |
OPTIONAL |
Agent ID which will handle request and return agent detail in response |
Response
{
"error": "",
"result": "success",
"data": {
"visitor": {
"id": "133",
"email": "site-visitor@chatsite.com",
"pass": "",
"name": "Site Visitor",
"display_name": "Site Visitor",
"profile_pic": "",
"profile_color": "#a1887f",
"role": "visitor",
"created_at": "2018-05-26 09:08:54",
"modified_at": "2018-05-26 09:08:54",
"contact_number": "12234566",
"remember_token": "",
"last_activity_time": "0000-00-00 00:00:00",
"mobile_last_activity_time": "0000-00-00 00:00:00",
"desktop_last_activity_time": "0000-00-00 00:00:00",
"last_login": "0000-00-00 00:00:00",
"user_status": "active"
},
"agent": {
"is_typing": "0",
"id": "5",
"name": "Babulal Kumwat",
"email": "",
"display_name": "Operator",
"profile_pic": "",
"profile_color": "#20a15d",
"role": "agent",
"last_activity_time": "2018-05-26 09:08:51",
"last_login": "2018-05-26 04:52:51",
"contact_number": "",
"profile_picture": "",
"profilePic": ""
},
"chat_session": {
"id": "339",
"site_id": "8",
"user_agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko\/20100101 Firefox\/60.0",
"port": "",
"requested_tag": "0",
"supported_tags": null,
"session_status": "open",
"session_type": "public"
},
"chatHistory": [
{
"chat_session_id": "339",
"sender_id": "5",
"chat_message": "Hello how can i help you.",
"local_id": "awb51527321864007",
"sort_order": "1527321864007",
"message_type": "text",
"message_status": "read",
"created_at": "2018-05-26 09:08:54",
"id": 4167,
"name": "Babulal Kumwat",
"display_name": "Admin",
"profile_color": "#20a15d",
"profile_pic": "",
"profilePic": ""
}, {
"chat_session_id": "339",
"sender_id": "5",
"chat_message": "There",
"local_id": "awb51527322001559",
"sort_order": "1527322001559",
"message_type": "text",
"message_status": "read",
"created_at": "2018-05-26 09:08:54",
"id": 4168,
"name": "Babulal Kumwat",
"display_name": "Admin",
"profile_color": "#20a15d",
"profile_pic": "",
"profilePic": ""
}, {
"id": 4169,
"chat_session_id": 339,
"chat_message": "I am a new customer.",
"sender_id": "133",
"name": "Site Visitor",
"sort_order": "1527325733201"
}
],
"last_id": 4169,
"message_stored": [4167, 4168, 4169]
}
}
Messages returned
HTTP STATUS CODE |
Description |
MESSAGE BODY |
200 |
Successfully Return |
Return data in JSON format. |
200 |
Authorization Error |
{"result":"failed","error":"Invalid access token or Token has been expired."} |
400 |
Request is malformed |
{"error": "invalid_request", "error_description": "description"} |
403 |
Forbidden |
Directory access is forbidden. |
404 |
Resource Not found |
The page you requested was not found. |