# Return message

When working with [Custom Actions](https://docs.robpod.cloud/coworker-projects#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="https://175138337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fvxlh3prlGsBGF30oqbYW%2Fuploads%2FNTSLLCOYTzkSLj4KbHSh%2Fai_return.png?alt=media&#x26;token=3156824b-7db8-47d7-89d8-e5664337f5e2" 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 %}
