Simple Opt Out Automation
Tags | Opt Out |
---|---|
Description | A simple channel app for automatically opting out inbound responses based on keyword detection. |
Features | JavaScript |
Type | Channel |
- Allows modifiction of the keywords in the Org Data Store.
- Could easily be extended to remove from lists, add tags, etc.
- Could be extended to automatically remove the opted out individual from the inbox.
var oow = ["fin", "stop", "désabonné"];
if (store.org.optOutWords == undefined) {
store.save("org", "optOutWords", JSON.stringify(oow));
} else {
oow = json(store.org.optOutWords);
}
var s = message.split(" ");
for (var i = 0; i < s.length; i++) {
var w = s[i].toLowerCase();
if (oow.indexOf(w) != -1) {
platform.whisper("Keyword detected " + w + " -- automatic opt out")
console.log("Opt Out automation -- opting out " + store.conversation.customerChannel);
platform.api.customers.updateCustomer(
{"customerId": store.conversation.customerId},
{"globalOptOut":true}
);
break;
}
}