AbstractAbstractcreateCreates a new webhook endpoint.
Generates a unique HTTP endpoint that will invoke the callback function when requests are received. The callback receives the WebhookRequest plus any extraArgs.
Provider-Specific Behavior:
authorization parameter.users.watch endpoint. Requires authorization parameter with Gmail scopes.Webhook creation options
Function receiving (request, ...extraArgs)
OptionalextraArgs?: TCallback extends (req: any, ...rest: R) => any ? R : []Additional arguments to pass to the callback (type-checked)
Optionalprovider?: AuthProviderOptional provider for provider-specific webhook routing
Optionalauthorization?: AuthorizationOptional authorization for provider-specific webhooks (required for Slack and Gmail)
Promise resolving to the webhook URL, or for Gmail, a Pub/Sub topic name
// Gmail webhook - returns Pub/Sub topic name
const topicName = await this.tools.network.createWebhook({
callback: this.onGmailNotification,
provider: AuthProvider.Google,
authorization: gmailAuth,
extraArgs: ["inbox"]
});
// topicName: "projects/plot-prod/topics/gmail-webhook-abc123"
// Pass topic name to Gmail API
await gmailApi.users.watch({
userId: 'me',
requestBody: {
topicName: topicName, // Use the returned topic name
labelIds: ['INBOX']
}
});
AbstractdeleteDeletes an existing webhook endpoint.
Removes the webhook endpoint and stops processing requests. Works with all webhook types (standard, Slack, and Gmail).
For Gmail webhooks: Also deletes the associated Google Pub/Sub topic and subscription.
For Slack webhooks: Removes the callback registration for the specific team.
For standard webhooks: Removes the webhook endpoint. Any subsequent requests to the deleted webhook will return 404.
The webhook identifier returned from createWebhook().
This can be a URL (standard webhooks), a Pub/Sub topic name (Gmail),
or an opaque identifier (Slack). Always pass the exact value returned
from createWebhook().
Promise that resolves when the webhook is deleted
Built-in tool for requesting HTTP access permissions and managing webhooks.
The Network tool serves two purposes:
IMPORTANT: Must be requested in the Twist or Tool Init method to declare HTTP access permissions. Without requesting this tool with the appropriate URLs, all outbound HTTP requests (fetch, etc.) will be blocked.
Permission Patterns:
*- Allow access to all URLshttps://*.example.com- Allow access to all subdomainshttps://api.example.com/*- Allow access to all paths on the domainhttps://api.example.com/v1/*- Allow access to specific path prefixWebhook Characteristics:
Example
Example