feat: Add CSAT response APIs (#2503)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Sojan Jose 2021-06-29 20:59:41 +05:30 committed by GitHub
parent 2e71006f9d
commit dd9d5e410c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 358 additions and 23 deletions

View file

@ -43,7 +43,7 @@ const generateCSATContent = (
const {
submitted_values: { csat_survey_response: surveyResponse = {} } = {},
} = contentAttributes;
const { rating, feedback } = surveyResponse || {};
const { rating, feedback_message } = surveyResponse || {};
let messageContent = '';
if (rating) {
@ -53,9 +53,9 @@ const generateCSATContent = (
messageContent += `<div><strong>${ratingTitle}</strong></div>`;
messageContent += `<p>${ratingObject.emoji}</p>`;
}
if (feedback) {
if (feedback_message) {
messageContent += `<div><strong>${feedbackTitle}</strong></div>`;
messageContent += `<p>${feedback}</p>`;
messageContent += `<p>${feedback_message}</p>`;
}
return messageContent;
};

View file

@ -21,7 +21,10 @@ describe('#generateBotMessageContent', () => {
expect(
generateBotMessageContent('input_csat', {
submitted_values: {
csat_survey_response: { rating: 5, feedback: 'Great Service' },
csat_survey_response: {
rating: 5,
feedback_message: 'Great Service',
},
},
})
).toEqual(
@ -33,7 +36,7 @@ describe('#generateBotMessageContent', () => {
'input_csat',
{
submitted_values: {
csat_survey_response: { rating: 1, feedback: '' },
csat_survey_response: { rating: 1, feedback_message: '' },
},
},
{ csat: { ratingTitle: 'റേറ്റിംഗ്', feedbackTitle: 'പ്രതികരണം' } }