Skip to content
Products
Open Auto Appy
Auto AppyFor developers15 min read

Lesson 6: Plug in the website and a daily report

SRSkyline RealtyLesson 6 of 6 · 15 min

Goal: The website form posts straight in, and a small script sends Arjun a daily pipeline report.

Website server → webhook URLAuto Appy runsScript with API keyDaily report to Arjun

This lesson is for the developer. Skip it if you don’t write code: everything before it works without any.

In Lesson 1 the form posted straight to the webhook URL, so the visitor saw Auto Appy’s JSON reply. Posting from the website’s server keeps the visitor on Skyline’s own thank-you page.

<?php
// enquiry.php: the form posts here; we forward to Auto Appy and redirect.
$payload = [
'name' => trim($_POST['name'] ?? ''),
'phone' => preg_replace('/\D/', '', $_POST['phone'] ?? ''),
'project' => $_POST['project'] ?? '',
'bhk' => $_POST['bhk'] ?? '',
'budget' => preg_replace('/\D/', '', $_POST['budget'] ?? ''),
'message' => trim($_POST['message'] ?? ''),
];
if (strlen($payload['phone']) === 10) $payload['phone'] = '91' . $payload['phone'];
$ch = curl_init(getenv('AUTOAPPY_WEBSITE_TRIGGER_URL'));
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Accept: application/json'],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_TIMEOUT => 20,
]);
curl_exec($ch);
curl_close($ch);
header('Location: /thank-you');

Two things this fixes at the source: phone numbers always get the 91 country code, and budgets are plain digits, so Lesson 2’s number conditions work.

  1. In Auto Appy, Settings → API keys → Create API key. Key name Daily pipeline report, Access Read and write (run history needs it today), Expiration After one year. Generate key and copy it once.

    Open API keysautoappy.com/settings/api-keys
  2. Store it on the server as AUTOAPPY_API_KEY.

  3. Schedule the script below to run at 8 pm (cron, or the hosting panel’s scheduler).

One key per integration, so it can be revoked on its own.
Create API key form with Key name Daily pipeline report, Access and Expiration
# daily_report.py: summarise today's runs for every Skyline workflow
import os, datetime, collections, requests
API = "https://api.autoappy.com"
H = {"Authorization": f"Bearer {os.environ['AUTOAPPY_API_KEY']}", "Accept": "application/json"}
today = datetime.datetime.now(datetime.timezone.utc).date().isoformat()
lines = []
for wf in requests.get(f"{API}/workflows", headers=H, timeout=30).json()["workflows"]:
data = requests.get(f"{API}/workflows/{wf['id']}/executions",
params={"status": "all", "per_page": 50}, headers=H, timeout=30).json()
runs = [r for r in data.get("data", []) if (r.get("executed_at") or "").startswith(today)]
if not runs:
continue
failed = sum(1 for r in runs if r.get("outcome") == "failed")
sources = collections.Counter((r.get("trigger") or {}).get("name", "Main") for r in runs)
by_source = ", ".join(f"{name} {n}" for name, n in sources.most_common())
lines.append(f"{wf['name']}: {len(runs)} runs ({by_source}), {failed} failed")
report = "Skyline today\n" + ("\n".join(lines) or "No runs today.")
print(report)
# Send it however you like: email, or a webhook into an Auto Appy workflow that WhatsApps Arjun.

Each run in the history response has executed_at, outcome (succeeded, failed, or still running) and trigger (which source started it). Pages hold up to 50 runs; read meta.last_page and add page=2… for busier workflows. Full details are in the API reference.

Try it yourself
  1. Send the report only when something failed, and otherwise just once a week.
  2. Revoke the key and run the script. What status code do you get?
  3. Rewrite the PHP handler so it also stores the enquiry in your own database before forwarding.
What you learned
  • Webhook URLsPost from a server for a clean thank-you page and clean data.
  • API keysOne named key per integration, with an expiry; revoke any time.
  • REST APIList workflows, read run history, change status, run workflows.
For trainers: how to teach this lesson
  • For mixed classes: run Part 1 as a demo for non-developers (“this is why the thank-you page looks nicer”), and let developers do Part 2 hands-on.
  • Security moment: ask where each secret lives (webhook URL, API key) and who could misuse it.