Building a Custom Task

Private Beta Feature

You can use the built-in AI tasks (i.e., agents) to streamline content management, but you can also create your own for more flexible integration with Liferay DXP. Follow this example to create a task that translates English blog content into Spanish.

First, log into your AI Hub account and click Agent Builder in the left menu.

Find the list of built-in tasks in the AI Hub instance.

If you don’t have an account, you can request to be part of the private beta testing program for AI Hub here.

To create a new Spanish translation task,

  1. You can start from scratch with the New button, but it’s easiest to copy an existing task. Find the Make Shorter task and click Actions ActionsDuplicate.

    You can duplicate an existing task.

  2. Now view the copied task by clicking Actions ActionsView.

  3. Edit these fields:

    Title: Spanish Translator

    Description: This writing agent takes your text and translates it to Spanish.

  4. Click Save.

  5. Now update the task logic. Click the View Workflow button.

  6. Change the title to Spanish Translator.

  7. In the task editor canvas, click on the Make Shorter node (if you duplicated the Make Shorter task).

  8. In the right node editor menu, change the label to Spanish Translator.

  9. Change the Node Name to translateToSpanish.

  10. Replace the Description with

    Translate text to Spanish using LLM models.
    
  11. Replace the Prompt with

    You are an expert translator. Your sole task is to translate the provided text to Spanish, preserving the exact semantic meaning of the input. If the text is already in Spanish, return it unchanged. Output only the translated text, with no explanations or commentary.
    
  12. Replace the User Message with

    This is the text to be translated: {{text}}
    

Your Spanish translator is ready to use.

  1. Click Update.

Now that the translation task is created, you can try it out.

Using the Custom Task

To test or use the custom task, go back to your running local instance that’s connected to AI Hub.

  1. Access a space in the Liferay CMS and edit a blog post.

    Tip

    You can generate a blog post with the built-in writing tasks. See Enhancing Content Management for more information.

  2. Open the AI Assistant chat box and enter this text:

Can you please translate this HTML into Spanish? [Copy the Source HTML of some content]

The AI Assistant is a supervisor agent to all of the individual tasks in your system. Ask it questions and it calls the relevant tasks to fulfill the request.

If you ask the supervisor chat agent to translate your blog post to French, it cannot.

The supervisor agent cannot translate to French because there is no applicable task/agent.

Now you can build custom tasks and call them with the supervisor agent.