Send message as user


Send message as user

POST

​/api​/public​/message​/send_message_as_user​/

Send messages on chat on behalf of your users. Depending on your needs, you can create new conversations for your users or add messages to the existing conversations. In case of mismatching user_id with conversation id, the message won't be sent and a proper response will appear.

Attributes
Type
Description
conversation
integer/string
ID of conversation.
user
integer
ID of user.
content
string
Content of message
state
string
You can choose between: 'snoozed', 'close' and 'active'
var data = JSON.stringify({
    "conversation": 748553,
    "content": "Message sent using API",
    "user": 926,
    "state": "active",
  });
  
  var xhr = new XMLHttpRequest();
  xhr.withCredentials = true;
  
  xhr.addEventListener("readystatechange", function () {
    if (this.readyState === 4) {
      console.log(this.responseText);
    }
  });
  
  xhr.open("POST", "https://.user.com/api/public/message/");
  xhr.setRequestHeader("authorization", "Token ");
  xhr.setRequestHeader("content-type", "application/json");
  
  xhr.send(data);