Enter new user input via script

Hello fellow Teneo-ers,

I know it’s possible to modify the user input with _.setUserInputText("new input") in a preprocessing script. However, I was wondering whether it’s also possible to “send” new/modified user input using a script during/after a flow.

The scenario is the following: I already have the setup for finding numerous entities and adding annotations to text given as input by the user. Now, as an alternative to entering/copying in that text, I would like to give the user the option of providing a link to a website instead, from which the relevant content is extracted. The extraction is currently handled by a Teneo integration.

Since the pipeline is already set up for processing direct user input, it would be easiest to send the extracted text as the new user input - as if the user had entered that text instead of giving the website link. However, I can’t seem to find the right way to pass the output of an integration/a global variable as the new user input.

I managed to overwrite the next user input with the desired content, but that requires an additional step of manually entering any user input first. As this would be confusing to the user, I would like to know if and how the new user input could be fed automatically via a script.

I’m still fairly new to Teneo, so apologies if I missed an obvious workaround. Any pointers from the community would be greatly appreciated! Thank you very much!

Hello Julia! And welcome to the Teneo community :smiling_face:

Thanks for your nice explanation. If I understood you correctly, the integration where the text is extracted from the url provided by the user, should always happen within the Pre-processing Global Script. Having said that, I can think of two different ways of solving this challenge:

  1. Localized version - Scripted-wise: If the integration method is specific to this situation and involves a small amount of code, you can simply migrate it into this Global script an make use of it at this same point.
  2. Global version - Solution-wise: in case you plan to make use of this method in a different place and you want to avoid duplication, you can use the code of the integration and create a Helper Class (stored in the Resource section) or on Solution Loaded. This way you can reuse the method across different scenarios.

If possible and wished, feel free to share a more concrete example to facilitate a more comprehensive and tailored proposal.
Hope this helps,

Sofía

1 Like

Hi Sofia,

Thank you so much for the tipps for streamlining my solution! That’s very helpful and I was able to adjust my solution accordingly.

If I may ask one more follow-up question, just because I’m curious, not because I actually need it: Do I understand it correctly that while you can modify user input there is no way to automatically send a user input?

I completely understand that “putting words in the user’s mouth” is usually not desired behaviour and it’s even difficult to come up with a reasonable use case.

Let’s assume the user types a question in English and would like a reply both in English and in Spanish. Would it be possible to imitate sending the question in Spanish as user input to maintain the symmetry? This could look something like this:

User Input: How can I change my order?
User Input (looks like user input, but automatically sent): ¿Cómo puedo cambiar mi pedido?

Bot answer: Click on the order number.
Bot answer: Haga clic en el número de pedido.

It’s perfectly fine if there’s no way to make this happen, I’m just asking out of curiosity. :wink:

Thank you very much!

Hi Julia (@julia-suter),

I think you can just add within the Global Scripts on Postprocessing a Machine Translation service to the mix, which translates then on runtime the bot’s English answer into Spanish and you can then add also this translated answer to the final output (see setOutputText in the Engine API) in order to provide the answer to the end user in both English and Spanish.
Regarding the Machine Translation service, would recommend looking into Azure’s AI Translator, works very nice and has a free trial option to test it out. :slight_smile:

Let us know if the suggested idea works for your scenario!

/Ben