# Return message

When working with [Custom Actions](/ai-coworker/coworker-projects.md#custom-actions), it is often necessary for the action to **return data** to the AI Assistant so that it can generate a response for the user.

For example, a user might ask, *“At what speed is the robot moving?”* In this case, the action should retrieve the relevant information and pass it back to the AI Assistant.

To do this, you can call the following function within your action:

{% code fullWidth="false" %}

```python
ai_return(message)
```

{% endcode %}

This function sends the data back to the AI Assistant, which then uses the real-time information provided by the robot to compose a natural-language response, such as: “The robot is moving at a speed of 250 mm/s.”

<figure><img src="/files/AqxLIDHgudyMR046CHxy" alt=""><figcaption></figcaption></figure>

{% tabs %}
{% tab title="Universal Robots" %}
{% hint style="info" %}
The **ai\_return** function can only be called once within a custom action, as it signals to the AI Assistant that the action has finished executing. If you need to return multiple data you can compose the message into a string.

```python
# get robot velocity
vel = get_actual_tcp_speed()
vel_string = str_cat("velocity: ", to_str(vel))
vel_string = str_cat(vel_string, " ")

# get robot position
pose = get_actual_tcp_pose()
pose_string = str_cat("position: ", to_str(pose))

# compose message
message = str_cat(vel_string, pose_string)

# return data to AI Assistant
ai_return(message)
```

{% endhint %}
{% endtab %}

{% tab title="Doosan Robotics" %}
{% hint style="info" %}
The **ai\_return** function can only be called once within a custom action, as it signals to the AI Assistant that the action has finished executing. If you need to return multiple data you can compose the message into a string.

```python
from DRCF import *

# get robot velocity
vel = get_current_velx()

# get robot position
pose, _ = get_current_posx()

# compose message
message = "velocity: {}, position: {}".format(vel, pose)

# return data to AI Assistant
ai_return(message)
```

{% endhint %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.robpod.cloud/ai-coworker/return-message.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
