# Examples & Use Cases Real-world scenarios showing how to connect RelayBook to the tools your team already uses. Each example includes the integration pattern, the endpoints involved, and sample code to get you started. > [!quote] The Central Hub > RelayBook stays simple: contacts, collaboration, and an API. ==Everything else connects through the API and webhooks.== --- ## Website Contact Form **Scenario:** Your marketing website has a "Get in touch" form. When a visitor submits it, their details are automatically added to your RelayBook book and tagged with a label. **Pattern:** Website → API → RelayBook ### How It Works 1. Visitor fills out the form on your website 2. Your backend receives the form submission 3. Your backend calls the RelayBook API to create a contact 4. Optionally, add a label like "Website Lead" ### Example: Node.js (Express) ```javascript app.post('/contact-form', async (req, res) => { const { name, email, company, message } = req.body; const [firstName, ...rest] = name.split(' '); const lastName = rest.join(' '); // Create the contact in RelayBook const contact = await fetch('https://app.relaybook.io/api/v1/contacts', { method: 'POST', headers: { 'Authorization': 'Bearer rlb_your_key', 'Content-Type': 'application/json', 'X-Book-ID': 'your-sales-book-id' }, body: JSON.stringify({ first_name: firstName, last_name: lastName, company: company, emails: [{ label: 'work', value: email }], notes: `Website inquiry: ${message}` }) }); const { data } = await contact.json(); // Add the "Website Lead" label await fetch(`https://app.relaybook.io/api/v1/contacts/${data.id}/labels`, { method: 'POST', headers: { 'Authorization': 'Bearer rlb_your_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ label_id: 'your-website-lead-label-id' }) }); res.json({ success: true }); }); ``` **Endpoints used:** - `POST /api/v1/contacts` — [[Contacts|Create contact]] - `POST /api/v1/contacts/{id}/labels` — [[Books & Labels|Add label]] --- ## CRM Sync **Scenario:** Your team uses a CRM alongside RelayBook. When a contact is created or updated in RelayBook, the CRM should be updated automatically. When a new lead is created in the CRM, it should appear in RelayBook. **Pattern:** Two-way sync using API + Webhooks ### Inbound: CRM → RelayBook When a new lead is created in your CRM, push it to RelayBook: ```javascript // Triggered by your CRM's webhook or event system async function syncToRelayBook(crmContact) { await fetch('https://app.relaybook.io/api/v1/contacts', { method: 'POST', headers: { 'Authorization': 'Bearer rlb_your_key', 'Content-Type': 'application/json', 'X-Book-ID': 'your-sales-book-id' }, body: JSON.stringify({ first_name: crmContact.firstName, last_name: crmContact.lastName, company: crmContact.company, emails: [{ label: 'work', value: crmContact.email }], phones: [{ label: 'mobile', value: crmContact.phone }] }) }); } ``` ### Outbound: RelayBook → CRM Set up a webhook to listen for `contact.created` and `contact.updated` events: ```javascript app.post('/relaybook-webhook', (req, res) => { const { event, data } = req.body; if (event === 'contact.created') { crmClient.createContact({ name: `${data.first_name} ${data.last_name}`, email: data.emails?.[0]?.value, company: data.company }); } if (event === 'contact.updated') { crmClient.updateContact(data.id, { name: `${data.first_name} ${data.last_name}`, email: data.emails?.[0]?.value, company: data.company }); } res.status(200).send('OK'); }); ``` > [!tip] Avoid infinite loops > When syncing both directions, make sure updates from the API don't trigger webhooks that push back to the CRM and vice versa. Use a flag or check the source of the change. **Endpoints used:** - `POST /api/v1/contacts` — [[Contacts|Create contact]] - Webhook: `contact.created`, `contact.updated` — [[Webhooks|Webhook events]] --- ## Slack Notifications **Scenario:** Your team wants to be notified in a Slack channel whenever a new contact is added to a specific book. **Pattern:** RelayBook → Webhook → Slack ### How It Works 1. Create a webhook in RelayBook subscribed to `contact.created` 2. Your server receives the webhook payload 3. Your server formats a Slack message and posts it via the Slack API ### Example ```javascript app.post('/relaybook-webhook', async (req, res) => { const { event, data, book_id } = req.body; if (event === 'contact.created') { const name = [data.first_name, data.last_name].filter(Boolean).join(' '); const email = data.emails?.[0]?.value || 'No email'; await fetch(SLACK_WEBHOOK_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: `New contact added: *${name}*\nCompany: ${data.company || '—'}\nEmail: ${email}` }) }); } res.status(200).send('OK'); }); ``` **Endpoints used:** - Webhook: `contact.created` — [[Webhooks|Webhook events]] --- ## Email Marketing List Sync **Scenario:** You use an email marketing tool (Mailchimp, ConvertKit, etc.) and want contacts with a specific label to be automatically added to a mailing list. **Pattern:** RelayBook → Webhook → Email tool API ### How It Works 1. Subscribe to `contact.created` and `contact.updated` webhooks 2. When a contact is created or updated, check if they have the "Newsletter" label 3. If they do, add their email to your marketing list ### Example ```javascript app.post('/relaybook-webhook', async (req, res) => { const { event, data } = req.body; if (event === 'contact.created' || event === 'contact.updated') { // Fetch the full contact to check labels const contactRes = await fetch( `https://app.relaybook.io/api/v1/contacts/${data.id}`, { headers: { 'Authorization': 'Bearer rlb_your_key' } } ); const contact = await contactRes.json(); const email = data.emails?.[0]?.value; if (!email) return res.status(200).send('OK'); // Add to your email marketing list await emailToolClient.addSubscriber({ email: email, firstName: data.first_name, lastName: data.last_name }); } res.status(200).send('OK'); }); ``` **Endpoints used:** - `GET /api/v1/contacts/{id}` — [[Contacts|Get contact]] - Webhook: `contact.created`, `contact.updated` — [[Webhooks|Webhook events]] --- ## Zapier / Make Automation **Scenario:** You want to connect RelayBook to hundreds of apps without writing code. Use Zapier or Make (formerly Integromatic) as the middleware. **Pattern:** RelayBook ↔ Zapier ↔ Any app ### Inbound: Any App → Zapier → RelayBook Set up a Zap where the **trigger** is from any app (e.g. "New row in Google Sheets", "New form response in Typeform") and the **action** is a Zapier Webhooks action that calls the RelayBook API: 1. **Trigger:** New row in Google Sheets 2. **Action:** Webhooks by Zapier → POST - URL: `https://app.relaybook.io/api/v1/contacts` - Headers: `Authorization: Bearer rlb_your_key`, `Content-Type: application/json`, `X-Book-ID: your-book-id` - Body: Map the spreadsheet columns to contact fields ### Outbound: RelayBook → Zapier → Any App Set up a Zap where the **trigger** is a Zapier Webhooks trigger (Catch Hook) that receives RelayBook webhook events: 1. **Create a webhook in RelayBook** pointing to your Zapier Catch Hook URL 2. **Trigger:** Webhooks by Zapier → Catch Hook 3. **Action:** Any app (e.g. "Create row in Google Sheets", "Send email via Gmail", "Create card in Trello") > [!tip] No code required > Zapier and Make handle the data mapping between RelayBook and other apps visually. This is the fastest way to connect RelayBook to your tool stack without writing any code. --- ## Scheduled Data Export **Scenario:** You want a nightly export of all contacts from a specific book for backup or reporting. **Pattern:** Cron job → API → File/Database ### Example: Python ```python import requests import json from datetime import datetime API_KEY = 'rlb_your_key' BOOK_ID = 'your-book-id' BASE_URL = 'https://app.relaybook.io/api/v1' headers = { 'Authorization': f'Bearer {API_KEY}', 'X-Book-ID': BOOK_ID } # Fetch all contacts with pagination all_contacts = [] offset = 0 limit = 200 while True: response = requests.get( f'{BASE_URL}/contacts?limit={limit}&offset={offset}', headers=headers ) data = response.json() contacts = data['data'] all_contacts.extend(contacts) if len(contacts) < limit: break offset += limit # Save to file filename = f'contacts-export-{datetime.now().strftime("%Y-%m-%d")}.json' with open(filename, 'w') as f: json.dump(all_contacts, f, indent=2) print(f'Exported {len(all_contacts)} contacts to {filename}') ``` Run this with a cron job (`crontab -e`): ``` 0 2 * * * /usr/bin/python3 /path/to/export_contacts.py ``` **Endpoints used:** - `GET /api/v1/contacts` — [[Contacts|List contacts]] (paginated) --- ## Event-Driven Cleanup **Scenario:** When a contact is deleted from RelayBook, you want to automatically clean up related records in other systems. **Pattern:** RelayBook → Webhook → Multiple systems ### Example ```javascript app.post('/relaybook-webhook', async (req, res) => { const { event, data } = req.body; if (event === 'contact.deleted') { const contactId = data.id; // Remove from CRM await crmClient.deleteContact(contactId); // Remove from email marketing list await emailTool.removeSubscriber(contactId); // Log the deletion await auditLog.record({ action: 'contact_deleted', contact_id: contactId, timestamp: new Date() }); } res.status(200).send('OK'); }); ``` **Endpoints used:** - Webhook: `contact.deleted` — [[Webhooks|Webhook events]] --- ## Integration Patterns Summary | Pattern | Direction | Uses | |---------|-----------|------| | **Push to RelayBook** | Inbound | API (`POST /contacts`) | | **Pull from RelayBook** | Inbound | API (`GET /contacts`) | | **React to changes** | Outbound | Webhooks | | **Two-way sync** | Both | API + Webhooks | | **No-code automation** | Both | Zapier/Make as middleware | > [!success] The Key Idea > RelayBook is the ==central hub for contact data==. External systems push data in through the API, and RelayBook pushes events out through webhooks. You choose how to connect — write custom code, use Zapier, or combine both. The name says it all: RelayBook literally relays contact information between your systems and people. --- **Back to:** [[Introduction|API Reference Introduction]]