Last active
August 20, 2018 14:01
-
-
Save tagazok/505e67f6202ef2c9e41a20addba9d397 to your computer and use it in GitHub Desktop.
babelbot-middleware-out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function output(context, next, done) { | |
| const { botMessages, brain } = context; | |
| const language = await brain.userGet(context.user, 'language'); | |
| if (language) { | |
| for (const message of botMessages) { | |
| if (message.type === 'text') { | |
| const translation = await translate(message.payload.value, { to: language }); | |
| message.payload.value = translation.text | |
| } | |
| } | |
| } | |
| return next(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment