Created
March 27, 2021 17:54
-
-
Save fedyk/7d8c9ec2033156911f966729a2f61535 to your computer and use it in GitHub Desktop.
Add avatars to visitors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{ | |
name: "Dwight Schrute", | |
email: "[email protected]", | |
avatar: "https://i.ibb.co/PYzBDTy/dwight.png" | |
}, { | |
name: "Kevin Malone", | |
email: "[email protected]", | |
avatar: "https://i.ibb.co/0n7D37f/kevin.png" | |
}, { | |
name: "Pam Beesly", | |
email: "[email protected]", | |
avatar: "https://i.ibb.co/LPjtyjp/pam.png" | |
}].forEach((user, index) => { | |
const visitor = App.collections.Visitors.at(index) | |
if (!visitor) { | |
return; | |
} | |
fetch("https://api.livechatinc.com/v3.2/agent/action/update_customer", { | |
headers: { | |
"authorization": `Bearer ${App.credentials.accessToken}`, | |
"content-type": "application/json", | |
}, | |
method: "POST", | |
body: JSON.stringify({ | |
customer_id: visitor.id, | |
...user, | |
}), | |
}).then(r => r.json()).then(r => console.log(r)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment