# Web Requests, Automation and Alerts.

Automation that responds immediately to on-chain circumnstances is extremely common for both developers, traders, or even generic purpose users.

Mercury allows you to build your automation workflows directly within a zephyr program. You'll be able to build transactions/payloads and send http requests, either directly to a tx submission system (e.g Horizon) or to a callback backend that then further handles the provided payload.

Another common use case are alerts, which are also enabled thorugh web requests (e.g a request to discord's API):

```rust
fn send_message(env: &EnvClient, source: ScVal, amount: ScVal) {
    let source = {
        let ScVal::Address(address) = source else { panic!() };
        address.to_string()
    };
    let key = env!("DISCORD_API");
    let body = format!(
        r#"{{"content": "{}"}}"#,
        format!(
            "New large deposit of {:?} XLM from {} on xycLoans testnet XLM pool.",
            amount, source
        )
    );
    env.send_web_request(AgnosticRequest {
        body: Some(body),
        url: "https://discordapp.com/api/channels/1234475897092968459/messages".into(),
        method: zephyr_sdk::Method::Post,
        headers: vec![
            ("Content-Type".into(), "application/json".into()),
            ("Authorization".into(), format!("Bot {}", key)),
        ],
    })
}
```

The above example is taken from [xycLoan's deposits discord bot](https://github.com/xycloo/zephyr-examples/tree/master/zephyr-discord-bot).

***

## Resources

Here are additional automation resources:

* <https://blog.xycloo.com/blog/blend-bot-with-zephyr-and-smart-accounts>
* <https://heytdep.github.io/post/20/post.html>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mercurydata.app/zephyr-full-customization/learn/web-requests-automation-and-alerts..md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
