# Agent

_class_ `rasa.core.agent.Agent`( _domain=None_, _policies=None_, _interpreter=None_, _generator=None_, _tracker_store=None_, _lock_store=None_, _action_endpoint=None_, _fingerprint=None_, _model_directory=None_, _model_server=None_, _remote_storage=None_, _path_to_model_archive=None_)

The Agent class provides a convenient interface for the most important Rasa functionality.

This includes training, handling messages, loading a dialogue model, getting the next action, and handling a channel.

```python
create_processor( _preprocessor=None_)  
```

Instantiates a processor based on the set state of the agent.

Return type  
`MessageProcessor`

```python
_async_ execute_action( _sender_id_, _action_, _output_channel_, _policy_, _confidence_)  
```

Handle a single message.

Return type  
[`DialogueStateTracker`](https://legacy-docs-v1.rasa.com/1.10.8/api/tracker/#rasa.core.trackers.DialogueStateTracker)

```python
handle_channels( _channels_, _http_port=5005_, _route='/webhooks/'_, _cors=None_)  
```

Start a webserver attaching the input channels and handling msgs.

Return type  
`Sanic`

```python
_async_ handle_message( _message_, _message_preprocessor=None_, _**kwargs_)  
```

Handle a single message.

Return type  
`Optional`[`List`[`Dict`[`str`, `Any`]]]

```python
_async_ handle_text( _text_message_, _message_preprocessor=None_, _output_channel=None_, _sender_id='default')  
```

Handle a single message.

If a message preprocessor is passed, the message will be passed to that function first and the return value is then used as the input for the dialogue engine.

The return value of this function depends on the `output_channel`. If the output channel is not set, set to `None`, or set to `CollectingOutputChannel` this function will return the messages the bot wants to respond.

### Example

```python
>>> from rasa.core.agent import Agent
>>> from rasa.core.interpreter import RasaNLUInterpreter
>>> agent = Agent.load("examples/restaurantbot/models/current")
>>> await agent.handle_text("hello")
[u'how can I help you?']
```

Return type  
`Optional`[`List`[`Dict`[`str`, `Any`]]]

```python
is_core_ready()  
```

Check if all necessary components and policies are ready to use the agent.

Return type  
`bool`

```python
is_ready()  
```

Check if all necessary components are instantiated to use agent.

Policies might not be available, if this is an NLU only agent.

Return type  
`bool`

```python
_classmethod_ load( _model_path_, _interpreter=None_, _generator=None_, _tracker_store=None_, _lock_store=None_, _action_endpoint=None_, _model_server=None_, _remote_storage=None_, _path_to_model_archive=None_)  
```

Load a persisted model from the passed path.

Return type  
[`Agent`](https://legacy-docs-v1.rasa.com/1.10.8/api/agent/#rasa.core.agent.Agent)

```python
_async_ load_data( _training_resource_, _remove_duplicates=True_, _unique_last_num_states=None_, _augmentation_factor=50_, _tracker_limit=None_, _use_story_concatenation=True_, _debug_plots=False_, _exclusion_percentage=None_)  
```

Load training data from a resource.

Return type  
`List`[`DialogueStateTracker`](https://legacy-docs-v1.rasa.com/1.10.8/api/tracker/#rasa.core.trackers.DialogueStateTracker)

```python
_async_ log_message( _message_, _message_preprocessor=None_, _**kwargs_)  
```

Append a message to a dialogue - does not predict actions.

Return type  
[`DialogueStateTracker`](https://legacy-docs-v1.rasa.com/1.10.8/api/tracker/#rasa.core.trackers.DialogueStateTracker)

```python
_async_ parse_message_using_nlu_interpreter( _message_data_, _tracker=None_)  
```

Handles message text and intent payload input messages.

### Parameters
- **message_data** ( _Text_) – Contain the received message in text or intent payload format.
- **tracker** ( [_DialogueStateTracker_](https://legacy-docs-v1.rasa.com/1.10.8/api/tracker/#rasa.core.trackers.DialogueStateTracker)) – Contains the tracker to be used by the interpreter.

Returns

The parsed message.

### Example

```json
{ "text": '/greet{"name":"Rasa"}', "intent": {"name": "greet", "confidence": 1.0}, "intent_ranking": [{"name": "greet", "confidence": 1.0}], "entities": [{"entity": "name", "start": 6, "end": 21, "value": "Rasa"}] }
```

Return type  
`Dict`[`str`, `Any`]

```python
persist( _model_path_)  
```

Persists this agent into a directory for later loading and usage.

Return type  
`None`

```python
_async_ predict_next( _sender_id_, _**kwargs_)  
```

Handle a single message.

Return type  
`Optional`[`Dict`[`str`, `Any`]

```python
toggle_memoization( _activate_)  
```

Toggles the memoization on and off.

Return type  
`None`

```python
train( _training_trackers_, _**kwargs_)  
```

Train the policies / policy ensemble using dialogue data from file.

### Parameters
- **training_trackers** – trackers to train on
- **kwargs** – additional arguments passed to the underlying ML trainer (e.g. keras parameters)

Return type  
`None`

```python
_async_ trigger_intent( _intent_name_, _entities_, _output_channel_, _tracker_)  
```

Trigger a user intent, e.g. triggered by an external event.

Return type  
`None`

👋 I can help you get started with Rasa and answer your technical questions.
