Last active
August 20, 2018 14:00
-
-
Save tagazok/030ad5d73d73c7799e125bea00fb3002 to your computer and use it in GitHub Desktop.
babelbot-middleware-in
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 input(context, next, done) { | |
| const { userMessage, brain } = context; | |
| if (userMessage.type === 'text') { | |
| const translation = await translate(userMessage.payload.value, { to: 'en' }); | |
| const language = translation.from.language.iso; | |
| await brain.userSet(context.user, 'language', language); | |
| userMessage.payload.value = translation.text; | |
| } | |
| return next(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment