Translation API integration

Hi Team,

I want to integrate a language translation API (post) in my chatbot. The flow goes like this:
message received from user -> call the translate API -> translate to English -> process -> generate output-> translate back to the native language of the user-> display on web

Should I call the API in after_incoming_middleware_hook and before_outgoing_middleware hook to translate the incoming and outgoing messages? Please guide me through this.

Thanks!

Hi @ruchi, thanks for posting on the forum.

One option could be :

  • Use a before_incomming_middleware hook to call your translation api and replace the sentence in the event variable with the api response.
  • Let botpress process the translated sentence.
  • Use a before_outgoing_middleware hook to call again the translation api with the botpress reply and again override the event variable with the response of the api call.

However, note that botpress can support all the 157 languages supported by fasttext so if the problem was using a non official language know that it’s possible.