Up

ImbaChat API

API for sending messages

Sending messages

Description This method will help to create a new group and add users listed in the request body to this group.

Request parameters

  1. imba_id - Required parameter, specifies belonging to the widget. The variable type is integer. If imba_id was not passed to the request, the server will return an error with code 422 and a message that the required parameter was not passed (see Possible errors)
  2. user_id - Required parameter, ID of the user (external site) from which the message is sent
  3. room_id - Required parameter, this parameter is the numeric identifier of the group, it is needed in order to be able to define the groups. The variable type is integer.
  4. password - Required parameter, password of the site user where the widget is installed. The variable type is string. If password was not passed to the request, the server will return an error with code 422 and a message that the required parameter was not passed (see Possible errors)
  5. message - string. Required parameter. The text of the transmitted message.

Request example: CURL:

curl --location --request POST 'http://api.imbachat.com/imbachat/v2/627/send_msg' \
--user imba_id:secret_key \
--form 'user_id="1"' \
--form 'room_id="1536"' \
--form 'message="api message"'

PHP:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://api.imbachat.com/imbachat/v2/627/send_msg',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('user_id' => '1','room_id' => '1536','message' => 'api message'),
  CURLOPT_USERPWD => "imba_id:secret_key",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response example:

{
    "success": true,
    "message": {
        "id": 4543,
        "uuid": "1536-1608275827-Z6Eq1W",
        "message": "api message",
        "time": "1608275827",
        "answer_to": 0,
        "liked": "0",
        "user_id": 2046,
        "room_id": "1536",
        "meta": []
    },
    "user": {
        "name": "spray",
        "user_id": "2046",
        "user_mail": "danil-kravtsiv@mail.ru",
        "chat_role": "admin",
        "status": 0,
        "avatar_url": false,
        "profile_url": false,
        "profiles": {
            "1": {
                "profile_id": 1,
                "name": "spray",
                "chat_role": "admin",
                "avatar_url": false,
                "profile_url": false,
                "user_id": "2046",
                "status": 0,
                "lastlogin": -1,
                "remote_user_id": 1
            }
        },
        "lastlogin": -1,
        "remote_user_id": 1
    },
    "relation": 0 
}

API for getting a list of users with filters applied

Description

This method returns a list of users that match the filters that were passed in the request.

Authorization:

To gain access to the request, you need to pass Basic authentication. Login - widget ID, password - secret key.

Filters:

  1. login - username registered in the chat
  2. id - Identification number in the imbachat system
  3. imba_id - Widget ID
  4. status - User status (user / administrator)
  5. last_message_date - date of the last message
  6. banned - ban status

Request example: CURL:

curl --location --request POST 'http://api.imbachat.com/imbachat/v2/627/get_users' \
--user imba_id:secret_key \
--form 'imba_id="627"' \
--form 'status="user"' \

PHP:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://api.imbachat.com/imbachat/v2/627/get_users',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('imba_id' => 627, 'status' => 'user'),
  CURLOPT_USERPWD => "imba_id:secret_key",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response example:

{
    "success": "true",
    "data": [
        {
            "id": 2046,
            "deleted_at": null,
            "created_at": "2020-11-23 05:26:41",
            "updated_at": "2020-11-24 06:59:54",
            "remote_user_id": "1",
            "user_data": null,
            "imba_id": 627,
            "login": "NULL",
            "password": "NULL",
            "status": "admin",
            "avatar_url": "https://secure.gravatar.com/avatar/3875115bacc48cca24ac51ee4b0e7975?s=48&d=identicon"
        }
    ],
    "code": 200
}

3 API for getting a list of rooms with filters applied

Description

This method returns a list of rooms that match the filters that were passed in the request, and a successful response is also returned if the "JWT" header with a token was passed.

Filters:

  1. room_type - type of rooms (dialogue - 0 / conference - 1)
  2. status - the status of the user in the room
  3. imba_id - Widget ID
  4. count_users - number of users
  5. last_message_date - date of the last message
  6. banned - ban status

Request example: CURL:

curl --location --request POST 'http://api.imbachat.com/imbachat/v2/627/get_rooms' \
--user imba_id:secret_key \
--form 'imba_id="627"' \
--form 'room_type="0"'

PHP:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://api.imbachat.com/imbachat/v2/627/get_rooms',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('imba_id' => 627, 'room_type' => '0'),
  CURLOPT_USERPWD => "imba_id:secret_key",
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response example:

{
    "success": "true",
    "data": [
        {
            "id": 1853,
            "pipe": "5fde659f0ba18_1608410527",
            "name": "Technical support",
            "admin_id": 2157,
            "type": 3,
            "tab": 0,
            "is_public": 0,
            "created_at": "2020-12-19 20:42:07",
            "updated_at": "2020-12-19 20:42:07",
            "deleted_at": null,
            "status": 0,
            "imba_id": 627
        }, 
        {
            "id": 1314,
            "pipe": "5fbcaf6a4ba35_1606201194",
            "name": "New conversation",
            "admin_id": 2046,
            "type": 0,
            "tab": 0,
            "is_public": 0,
            "created_at": "2020-11-24 06:59:54",
            "updated_at": "2020-11-24 06:59:54",
            "deleted_at": null,
            "status": 0,
            "imba_id": 627
        }
    ],
    "code": 200
}
3 comments
  • I added messenger to wordpress and also used the data and instructions above, everything works! Thank you!
  • Insightful article on using the ImbaChat API for sending messages with a chat bot! It provides a clear explanation of how to integrate and leverage the API to enable automated messaging capabilities in your chat application. The step-by-step instructions and code examples make it easy to understand the process of setting up a chat bot and sending messages programmatically. This resource is invaluable for developers looking to enhance their chat systems with chat bot functionality