Comments (1)
Let's think of the CSAT survey as a business initiated flow. All business initiated flows need to respect the 24hr policy, we therefore should track the last user message that we got.
Possible Solution
Define a required inactivity period to be eligible for a survey (quiet time 60s). The implementation will sleep for a minute, and check if the user has not messaged the app in the last minute. If that is not the case wait for a final second time.
-
Add a label this.last_user_activity = "timestamp" in https://github.com/fbsamples/original-coast-clothing/blob/master/services/user.js and keep it up to date with the latest user time the user engaged with us. Also add a function called withinPolicyMessagingWindow() { return now - this.last_user_activity < 24hr}
-
Edit genAgentRating on survey.js to:
static genAgentRating(agent) {
// This is only triggered 1 min after talking with an agent as long as nothing else happened in between
delay = "60000";
setTimeout(() => sendCSATRequest(user, agent, delay), delay);
return;
}
- Add to on survey.js the sendCSATMessage function:
function sendCSATMessage(user, agent, delay){
// It's a good practice to always validate this even if is not possible given the proposed params.
if(!user.withinPolicyMessagingWindow())
return;
// Once HOP Support is done, check that this app owns the thread.
if(user.primaryReceiver() !== config.app_id)
return;
if(Date.now() - delay < user.last_user_activity){
return;
}
let response = Response.genQuickReply(
i18n.__("survey.prompt", {
agentFirstName: agent
}),
[
{
title: "\uD83D\uDE00",
payload: "CSAT_GOOD"
},
{
title: "\uD83D\uDE42",
payload: "CSAT_AVERAGE"
},
{
title: "\uD83D\uDE41",
payload: "CSAT_BAD"
}
]
);
// send the message
let requestBody = {
recipient: {
id: user.psid
},
message: response
};
GraphAPi.callSendAPI(requestBody);
}
from original-coast-clothing.
Related Issues (20)
- webokqiioo
- https://labqiioo.com/Callback URL HOT 1
- Relojerias Labqurzor HOT 1
- Relojerias Labqurzor > https://githubcom/fbsamples/blob/ecb454f0e67d49d7342b805d2288483e11a8cf15/applabqiioo/app.js#L27> https://github.com/fbsamples/blob/ecb454f0e67d49d7342b805d2288483e11a8cf15/app.js#L27
- Short description of the feature HOT 2
- RGPD problems (Europe) : impossible to solve ? HOT 4
- Test issue to verify ticket assignment HOT 1
- No Greetings Messages with buttons and products are not being displayed HOT 2
- Unable to callSubscriptionsAPI HOT 1
- Bot Not as it should HOT 1
- How does OriginalCoastClothing avoid the "User wants to send you a message" speed bump? HOT 2
- Pause automation on Human Agent Replies from Page Inbox HOT 2
- Send fails for Apps without advance User Profile Access
- ERROR - Need a proper API_URL in the .env file HOT 1
- App Type needs to be "Business" HOT 1
- webview does not load on messenger.com HOT 2
- Short description of the issue HOT 1
- Short description of the issue
- I can't read the message from instagram dm HOT 3
- Short description of the feature HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from original-coast-clothing.