Skip to content

Instantly share code, notes, and snippets.

@tagazok
Last active August 20, 2018 14:00
Show Gist options
  • Select an option

  • Save tagazok/030ad5d73d73c7799e125bea00fb3002 to your computer and use it in GitHub Desktop.

Select an option

Save tagazok/030ad5d73d73c7799e125bea00fb3002 to your computer and use it in GitHub Desktop.
babelbot-middleware-in
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