Advertisement
Dzhubal

Untitled

Feb 1st, 2021
869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var messageText = 'Тут текст сообщения',
  2.     http = new XMLHttpRequest(),
  3.     url = 'https://api.carrotquest.io/v1/users/' + carrotquest.data.user.id + '/startconversation',
  4.     params = 'auth_token=' + carrotquest.data.auth_token + '&id_as_string=true&body='+messageText;
  5. http.open('POST', url, true);
  6. http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
  7. http.send(params);
  8.  
  9. //если нужно открыть в чате этот диалог
  10. http.onreadystatechange = function() {
  11.     if (http.readyState != 4) return;
  12.     if (http.status == 200) {
  13.         var json = JSON.parse(http.responseText);
  14.         carrotquest.messenger.toStateNo();
  15.         carrotquest.messenger.toStateOpened({id: json.data.id});
  16.     };
  17. };
  18. //если нужно открыть в чате этот диалог
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement