Skip to content

Instantly share code, notes, and snippets.

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

  • Save tagazok/505e67f6202ef2c9e41a20addba9d397 to your computer and use it in GitHub Desktop.

Select an option

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