# Gateway Multi-Profilo Systemd — Troubleshooting

## Problema: "No messaging platforms enabled"

Il gateway Hermes non carica automaticamente il `.env` del profilo quando avviato
via systemd con `--profile <nome>`, anche con `HERMES_HOME` impostato.

### Causa

Il codice Hermes in `gateway/config.py` (riga 1214) fa:
```python
telegram_token = os.getenv("TELEGRAM_BOT_TOKEN")
```

systemd imposta `HERMES_HOME` ma **non carica** automaticamente il `.env`
del profilo. Hermes carica `.env` solo se trova `$HERMES_HOME/.env` tramite
`load_dotenv` all'avvio, ma quando usa `--profile`, HERMES_HOME viene
ignorato a favore della directory del profilo — e dotenv non viene chiamato.

### Soluzione

Nel file `.service` di systemd, aggiungere il token direttamente come
`Environment`:

```
[Service]
Environment="TELEGRAM_BOT_TOKEN=***at Service)]

Non funziona usare `EnvironmentFile=/path/.env` perché systemd non supporta
variabili su più righe e alcuni caratteri speciali (`!`, `-`, `:`) rompono
il parsing YAML.

### Test di Connessione

```bash
# Con single quotes (fondamentale se il token ha !)
curl -s 'https://api.telegram.org/bot<TOKEN>/getMe'
# Output atteso:
# {"ok":true,"result":{"id":...,"is_bot":true,"first_name":"...","username":"..."}}
```
