Docs / Builder

Smart Paste

The smart paste functions let users paste any URL — a raw webhook URL copied from Discord settings, a Slack app config page, etc. — and get back a notifly URL ready to use.

smartParse()
paste any webhook url
notifly url

smartParse()

The all-in-one function. Accepts either a raw provider URL (https://discord.com/...) or an existing notifly URL (discord://...) and returns a normalised result.

signature
function smartParse(input: string): DetectResult | null
DetectResult
interface DetectResult {
  service: string;
  notiflyUrl: string;
  fields: Record<string, string>;
}
typescript
import { smartParse } from '@ambersecurityinc/notifly/builder';

// Raw Discord webhook URL
const r1 = smartParse('https://discord.com/api/webhooks/1234567890/mytoken');
// → {
//   service: 'discord',
//   notiflyUrl: 'discord://1234567890/mytoken',
//   fields: { webhook_id: '1234567890', webhook_token: 'mytoken' },
// }

// Already a notifly URL — decomposed
const r2 = smartParse('discord://1234567890/mytoken');
// → { service: 'discord', notiflyUrl: 'discord://1234567890/mytoken', fields: { ... } }

// Unknown URL
const r3 = smartParse('https://example.com/something');
// → null

detectAndConvert()

Convert a raw provider URL (http/https from a service's dashboard) to a notifly URL. Returns null if the URL doesn't match any known pattern.

typescript
import { detectAndConvert } from '@ambersecurityinc/notifly/builder';

const result = detectAndConvert(
  'https://hooks.slack.com/services/T00/B00/XXXX'
);
// → { service: 'slack', notiflyUrl: 'slack://T00/B00/XXXX', fields: { ... } }

// Won't match a notifly URL (use decomposeUrl for that)
detectAndConvert('discord://123/abc'); // → null

isRawServiceUrl()

Returns true if the string looks like a raw provider URL (http/https), rather than a notifly scheme URL.

typescript
import { isRawServiceUrl } from '@ambersecurityinc/notifly/builder';

isRawServiceUrl('https://discord.com/api/webhooks/123/abc'); // true
isRawServiceUrl('discord://123/abc');                        // false
isRawServiceUrl('not a url at all');                         // false

Supported raw URL conversions

Service Raw URL pattern Converted to
Discord discord.com/api/webhooks/ID/TOKEN discord://ID/TOKEN
Slack hooks.slack.com/services/A/B/C slack://A/B/C
ntfy ntfy.sh/TOPIC ntfy://TOPIC

More raw URL patterns will be added as services are updated to expose copyable webhook URLs. Use buildUrl() with manual field entry for services not yet covered.

← Previous URL Generation Next → Custom Services