Skip to main content

Abstra Agents

Similar to the concept of microservices, Abstra allows you to combine multiple specialized workflows to build your project.

We're launching a new feature called Agents, which makes it much easier to set up and manage workflow connections.

Use Case 1: Workflow Reuse

A great example is when you need to reuse some logic.

Imagine you're a marketing operations professional who has just integrated WhatsApp into your workflow for marketing purposes.

Most likely, you’d implement the entire business logic in the same place as the integration logic. This works well—until customer support decides to use the same WhatsApp account for customer communication.

Now, you have a problem. You don’t want to mix your marketing logic with customer support logic, but at the same time, you don’t want to duplicate the entire WhatsApp integration in another project, since webhooks are globally configured.

You could create a microservice by setting up a separate workflow for the WhatsApp integration and then connecting different department workflows to it through hooks.

However, this means you’d have to manage the API yourself, ensuring every request follows a consistent format. You might even end up in "callback hell," juggling JSON requests across multiple hooks for each communication message.

With Abstra Agents, you can turn an entire workflow into an API that others can use as stages in their workflows.

Instead of manually managing API interactions, you can simply use an Agent stage.

  • An Agent stage connects to other workflows, making it easy to send and receive tasks.
  • On the agent side, a corresponding client stage is created, which sends and receives tasks to and from the client stages that connect to it through their Agent stages.

With this setup, communication between workflows is as simple as sending and receiving tasks.

Use Case 2: External Workflows

Just as you can use internal services via the Agent stage, you can also connect to external vendor services in the same way.

We're gradually expanding a library of prebuilt Agents, mostly for integrations and common AI tasks, such as:

  • Document processing
  • CAPTCHA solving

Use Case 3: Becoming a Vendor

Beyond consuming external Agents, you can also provide services to the public or your existing customers.

We're currently working with a few beta partners who are leveraging the Workflows as a Service concept.

Beta Status and Feedback

As this is a beta feature, you may encounter some bugs or inconsistencies. If you do, please reach out to support@abstra.io—we’d love to hear your feedback!

Likewise, if you're interested in providing or consuming specific services through workflows, contact us at partners@abstra.io.

How to create your first Agent

To create an Agent, you need to use the client stages. All messages received by this stage comes with one additional field called: connection_token.

This connection token identify the connection between the client and the agent. This token is unique for each connection and is used to send messages back to the client.

You should use this token to get information about the clients and send messages back to them. Here is one example code on the server:

from abstra.agents import get_connections
from abstra.tasks import get_trigger_task

task = get_trigger_task()
connection_token = task['connection_token']

for connection in get_connections():
print(connection.token)
print(connection.agent_project_id)
print(connection.agent_stage_id)
print(connection.client_project_id)
print(connection.client_stage_id)

Wenever you need to send a message back to the client, you should just send a task with the connection_token field filled with the token you want to send the message to.

Here is an example code on the server:

from abstra.tasks import get_tasks, send_task
from abstra.agents import get_connections

my_client_project_id = ' ... '

for conn in get_connections():
if conn.client_project_id == my_client_project_id:
send_task("hello", {
'message': 'Hello, client!',
'connection_token': conn.token
})

This method will send many messages to all connections between the same client and the agent. For each pair of stages (client and agent) you will have a different connection token.

Also, for each environment (local dev and production) you will get a different connection token. So if you want to send just one message to a specific client on a specific environment, you should use the connection token instead.

Example: Timer Agent

This picture illustrates a simple timer agent that receives tasks for delaying or scheduling new tasks.

Agent example

You may notice there are 2 "client stages" in this workflow, which means there are 2 "distinct APIs" that your clients may send tasks to.

If you want to consume this agent, on the client project you should create a new "agent stage", which will be connected to the client stage on the agent project.

As shown in the image bellow, the client should have the project id of the agent. This is just a temporary experience, we are working on a better way to connect the client to the agent by having a search bar to find the agent project.

Client example

Since in this example, we have 2 options in the dropdown, one for each client stage in the agent project.

Client example collapsed