Как прикрутить Api кнопку из AmoCrm в React-js
ссылка на документацию API кнопки https://www.amocrm.ru/developers/content/web_sdk/social_button_api
есть пример на JS
< script type = "text/javascript" >
window.amoSocialButtonConfig = {
hidden: true,
onlinechat: {
mode: "frame",
container: '#custom_chat_holder',
user_id: "123456", // id пользователя radist.online
theme: {
header: false
}
}
}; <
/script>
<
script > (function(a, m, o, c, r, m) {
a[m] = {
id: "134351",
hash: "aca2a27a96c06d83b3004cff4fd8e71888a3a047039762406141e075f4bf8b13",
locale: "ru",
inline: false,
setMeta: function(p) {
this.params = (this.params || []).concat([p])
}
};
a[o] = a[o] || function() {
(a[o].q = a[o].q || []).push(arguments)
};
var d = a.document,
s = d.createElement('script');
s.async = true;
s.id = m + '_script';
s.src = 'https://gso.amocrm.ru/js/button.js?1645444737';
d.head && d.head.appendChild(s)
}(window, 0, 'amoSocialButton', 0, 0, 'amo_social_button')); < /script>
<
script type = "text/javascript" >
function showChat() {
amo_social_button.setMeta({
bot_params: {
username: "User Name",
company_chat_id: "d67b19e2-5ae6-4764-97ed-06909602eaf9" // id чата компании radist.online
}
});
amoSocialButton('runChatShow');
}
function hideChat() {
amoSocialButton('runChatHide');
}
// docs: https://www.amocrm.ru/developers/content/web_sdk/social_button_api#JavaScript-%D0%BC%D0%B5%D1%82%D0%BE%D0%B4%D1%8B
<
/script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
<div id="custom_chat_holder" style="width: 33%;height: 400px;"></div>
<button name="support" onclick="showChat()">Support</button>
<button name="close_support" onclick="hideChat()">Close</button>
</body>
</html>