open-wa / wa-automate-nodejs

💬 🤖 The most reliable tool for chatbots with advanced features. Be sure to 🌟 this repository for updates!
https://docs.openwa.dev/
Other
3.14k stars 600 forks source link

Chatwoot issues from emails: CSAT & VCARD #2997

Closed smashah closed 1 year ago

smashah commented 1 year ago
smashah commented 1 year ago

CSAT messages are blocked by:

https://github.com/chatwoot/chatwoot/issues/5291

smashah commented 1 year ago

Actually:

  1. Listen to "event": "conversation_updated" for "status": "resolved" (resolvedEventData)

  2. const cstMsg = resolvedEventData.messages.find(x=>x.content_type === 'input_csat')

  3. cstMsg.content is missing link, usually 1-5 stars:

    CleanShot 2023-01-01 at 08 11 59@2x
  4. Use GET https://app.chatwoot.com/api/v1/accounts/ACCOUNT_ID/conversations/CONVO_ID/messages

  5. const actualCstMsg = messages.payload.find(x=>x.id==cstMsg.id)

  6. send text with link: actualCstMsg?.content

Note:

You could actually send a listMessage instead with 1-5 (license dependant). The response to that will be used send a PUT request to submit CSAT report:

CSAT content looks something like this:

Please rate this conversation, https://app.chatwoot.com/survey/responses/d2d734a5-d1dc-4048-910b-7a8462d938a9

Use regex to extract link:

  1. Extract the csatlink: const csatLink = "Please rate this conversation, https://app.chatwoot.com/survey/responses/d2d734a5-d1dc-4048-910b-7a8462d938a9".match(/(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])/gi)[0]

  2. Send the csat listMsg OR link message based on license

smashah commented 1 year ago

@github-actions run

âš¡ Release! âš¡ ```js (async () => { function exec(cmd) { try { execSync(cmd, {stdio: 'inherit'}) } catch (error) { console.log(`Status Code: ${error.status} with '${error.message}'`); } } //set the version type process.env.VERS = "minor" // Config const gitUserEmail = "github-actions[bot]@users.noreply.github.com"; const gitUserName = "github-actions[bot]"; exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`); exec(`git config --global user.email "${gitUserEmail}"`); exec(`git config --global user.name "${gitUserName}"`); exec(`npm i -D`); exec(`npm run release-ci $VERS`); // types only package exec('npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN') exec(`npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN && npm run types:publish `); exec(`git commit -a -m 'updated types-only package'`); exec(`git push --force`); //comment on the issue var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString(); await postComment(result); //create changelog image exec(`npm run release-image`); exec(`git commit -a -m 'updated release-image'`); exec(`git push --force`); })(); ```
smashah commented 1 year ago

Changelog

🚀 Release 4.55.0 (2023-01-08)