# Wake an agent with a message

Send email, a Telegram message, a schedule or an HTTP request to a sleeping VM, and have an agent in the VM answer it.

Source: https://slashinfra.com/docs/agents/triggers
Last modified: 2026-11-30T16:36:19.000Z

Four sources wake a sleeping VM for work: email, Telegram, a schedule and an HTTP request. The VM wakes, the work starts, and an agent you start in the VM answers the message.

Figure: An email, a Telegram message, a schedule or an HTTP request wakes the same sleeping VM.

## Before you start

- A VM. Create one as shown in [From your terminal](https://slashinfra.com/docs/start/cli), and keep its id in `VM`. 
- Your API key in `SI_API_KEY`, for step 4. 
- A Telegram account and a bot token from [@BotFather](https://t.me/BotFather), for step 2.

## 1. Email

```bash
VM=wake-example
si create --name "$VM"
si svm inbox enable "$VM"
si svm inbox "$VM"
```

Output

```text
address:  0zs0pshr3x@slashinfra.dev
enabled:  yes
webhook:  -
```

Send a mail from your mail app to the address. The VM wakes, and the mail is saved on its disk. Read it inside the VM:

```bash
si exec "$VM" -- inbox ls --unread
```

Every email wakes the VM. An enabled inbox with no sender rule accepts mail from anyone. Limit the senders in a profile, or run `si svm inbox disable "$VM"` when you do not need it.

## 2. Telegram

Connect the bot. Use a file for the token, so it does not appear in your shell history:

```bash
si svm inbox telegram "$VM" connect --token-file ~/.telegram-token
```

Output

```text
bot:        @build_1_bot
pair code:  k3m9q2x7
send /start k3m9q2x7 to the bot within ten minutes
```

Send `/start k3m9q2x7` to the bot in Telegram. The code is single use. Only paired users reach the inbox.

Let the VM sleep: leave it with nothing running for at least 60 seconds. Then send the bot a message. The message wakes the VM and lands in its inbox.

Start an agent in the VM to answer it. The agent replies with `inbox reply`, which works only for Telegram messages:

```bash
si agent run "$VM" --agent claude --cwd /home/user -- 'Answer the unread Telegram message with inbox reply.'
```

## 3. Schedule

```bash
si svm schedule add "$VM" --name nightly --cron '0 3 * * *' --tz Europe/Berlin -- 'hc run claude "Read the inbox and answer what needs an answer."'
```

Output

```text
nightly
next fire: 2026-11-14 02:00:00Z
```

A due schedule wakes the VM and starts within about 90 seconds. A cron job inside the VM cannot wake it, so use a schedule for work at a set time.

## 4. HTTP

An HTTP request to the VM wakes it and runs the command in the request:

```bash
curl -sS -i -H "Authorization: Bearer $SI_API_KEY" --data-binary 'inbox ls --unread' "https://$VM.slashinfra.dev/bin/bash"
```

Output

```text
X-Exit-Code: 0
...
```

Check `X-Exit-Code`. An HTTP `200` alone does not mean the command succeeded.

## Check it works

You should now see the agent’s reply in your Telegram chat. The VM had nothing to do for a minute before your message, so it was asleep when the message arrived.

## If it doesn’t work

| Symptom | Cause | Fix |
| --- | --- | --- |   
| The bot connect command answers `inbox_disabled` | The inbox is off | Run `si svm inbox enable "$VM"`. | 
| The bot gives no answer to `/start` | The pairing code expired after ten minutes | Make a new code with `si svm inbox telegram "$VM" pair`. | 
| Mail never arrives | The inbox is off, so the mail is rejected | Run `si svm inbox "$VM"` and check that `enabled` says `yes`. |

## Clean up

Remove the bot and its webhook with `si svm inbox telegram "$VM" disconnect`. Then remove the schedule with `si svm schedule rm "$VM" <schedule-id>`, using the id that `si svm schedule ls` shows. Messages already saved stay on the VM until you delete it.

## Next

- [Email](https://slashinfra.com/docs/platform/email): addresses, plus tags and the inbox limits. 
- [Schedules](https://slashinfra.com/docs/platform/schedules): commands and messages at a cron time. 
- [Sleep and wake](https://slashinfra.com/docs/how/sleep-and-wake): what keeps a VM awake and what wakes it.
