Skip to content

Instantly share code, notes, and snippets.

@fedyk
Created March 27, 2021 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedyk/7d8c9ec2033156911f966729a2f61535 to your computer and use it in GitHub Desktop.
Save fedyk/7d8c9ec2033156911f966729a2f61535 to your computer and use it in GitHub Desktop.
Add avatars to visitors
[{
name: "Dwight Schrute",
email: "d.schrute@dunder-mifflin.com",
avatar: "https://i.ibb.co/PYzBDTy/dwight.png"
}, {
name: "Kevin Malone",
email: "k.malone@dunder-mifflin.com",
avatar: "https://i.ibb.co/0n7D37f/kevin.png"
}, {
name: "Pam Beesly",
email: "p.beesly@dunder-mifflin.com",
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