# Agent

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.

## Methods

### `create_processor(preprocessor=None)`  
Instantiates a processor based on the set state of the agent.  
_Return type:_ `MessageProcessor`

### `_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.13/api/tracker/#rasa.core.trackers.DialogueStateTracker)

### `handle_channels(channels, http_port=5005, route='/webhooks/', cors=None)`  
Start a webserver attaching the input channels and handling msgs.  
_Return type:_ `Sanic`

### `_async handle_message(message, message_preprocessor=None, **kwargs)`  
Handle a single message.  
_Return type:_ `Optional`[`List`[`Dict`[`str`, `Any`]]

### `_async handle_text(text_message, message_preprocessor=None, output_channel=None, sender_id='default')`  
Handle a single message.

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`]]

### `is_core_ready()`  
Check if all necessary components and policies are ready to use the agent.  
_Return type:_ `bool`

### `is_ready()`  
Check if all necessary components are instantiated to use agent.  
_Return type:_ `bool`

### `_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.13/api/agent/#rasa.core.agent.Agent)

### `_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.13/api/tracker/#rasa.core.trackers.DialogueStateTracker)

### `_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.13/api/tracker/#rasa.core.trackers.DialogueStateTracker)

### `_async parse_message_using_nlu_interpreter(message_data, tracker=None)`  
Handles message text and intent payload input messages.

Returns:

```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`]

### `persist(model_path)`  
Persists this agent into a directory for later loading and usage.  
_Return type:_ `None`

### `_async predict_next(sender_id, **kwargs)`  
Handle a single message.  
_Return type:_ `Optional`[`Dict`[`str`, `Any`]

### `toggle_memoization(activate)`  
Toggles the memoization on and off.   
_Return type:_ `None`

### `train(training_trackers, **kwargs)`  
Train the policies / policy ensemble using dialogue data from file.

Parameters:
- **training_trackers** – trackers to train on

_Return type:_ `None`

### `_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.
