Create conversation


Send a conversation message using our API. Easy way to integrate our conversation into other applications.

You can send HTML inside API message. For example, as a content we can set:

Hi <b>user</b>, enjoy our product!

Themessage will be shown as follow:

Hi user, enjoy our product!
POST

/conversations/

Attributes
Type
Description
client_user_id
integer/string
ID of clientuser
content
string
HTML can be used inside
user
integer
Unique agent ID, can be found here
source
integer
Find source types here
source_context
array
JSON array of additional fields if needed
curl -X POST -H "Authorization: Token <your_64_char_api_key>" -H "Content-Type: application/json" -d '{
    "content": "Message sent using API",
    "user": 926,
    "source": 2,
    "source_context": {
      "name": "This is source_context used in API",
      "id": 123
    }
}' "https://app.userengage.com/api/public/users/:client_user_id/conversations/"

Response

201 created
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://app.userengage.com/api/public/users/:client_user_id/conversations/",
  "method": "POST",
  "headers": {
    "authorization": "Token <your_64_char_api_key>",
    "content-type": "application/json"
  },
  "processData": false,
  "data": "{\n    \"content\": \"Message sent using API\",\n    \"user\": 926,\n    \"source\": 2,\n    \"source_context\": {\n    \t\"name\": \"This is source_context used in API\",\n    \t\"id\": 123\n    }\n}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
var data = JSON.stringify({
  "content": "Message sent using API",
  "user": 926,
  "source": 2,
  "source_context": {
    "name": "This is source_context used in API",
    "id": 123
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://app.userengage.com/api/public/users/:client_user_id/conversations/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);
var request = require("request");

var options = { method: 'POST',
  url: 'https://app.userengage.com/api/public/users/:client_user_id/conversations/',
  headers:
   { 'content-type': 'application/json',
     authorization: 'Token <your_64_char_api_key>' },
  body:
   { content: 'Message sent using API',
     user: 926,
     source: 2,
     source_context: { name: 'This is source_context used in API', id: 123 } },
  json: true };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
<?php

$request = new HttpRequest();
$request->setUrl('https://app.userengage.com/api/public/users/:client_user_id/conversations/');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'content-type' => 'application/json',
  'authorization' => 'Token <your_64_char_api_key>'
));

$request->setBody('{
    "content": "Message sent using API",
    "user": 926,
    "source": 2,
    "source_context": {
      "name": "This is source_context used in API",
      "id": 123
    }
}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}
import requests

url = "https://app.userengage.com/api/public/users/:client_user_id/conversations/"

payload = "{\n    \"content\": \"Message sent using API\",\n    \"user\": 926,\n    \"source\": 2,\n    \"source_context\": {\n    \t\"name\": \"This is source_context used in API\",\n    \t\"id\": 123\n    }\n}"
headers = {
    'authorization': "Token <your_64_char_api_key>",
    'content-type': "application/json"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
import http.client

conn = http.client.HTTPSConnection("app.userengage.com")

payload = "{\n   \"content\": \"Message sent using API\",\n    \"user\": 926,\n    \"source\": 2,\n    \"source_context\": {\n    \t\"name\": \"This is source_context used in API\",\n    \t\"id\": 123\n    }\n}"

headers = {
    'authorization': "Token <your_64_char_api_key>",
    'content-type': "application/json"
    }

conn.request("POST", "/api/public/users/:client_user_id/conversations/", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))