| = Webhook Component |
| :doctitle: Webhook |
| :shortname: webhook |
| :artifactid: camel-webhook |
| :description: Expose webhook endpoints to receive push notifications for other Camel components. |
| :since: 3.0 |
| :supportlevel: Stable |
| :tabs-sync-option: |
| :component-header: Only consumer is supported |
| |
| *Since Camel {since}* |
| |
| *{component-header}* |
| |
| |
| The Webhook meta-component allows other Camel components to configure webhooks on a remote webhook provider and |
| listen for them. |
| |
| .The following components currently provide webhook endpoints: |
| |
| - xref:telegram-component.adoc[Camel Telegram] |
| - xref:whatsapp-component.adoc[Camel WhatsApp] |
| |
| Maven users can add the following dependency to their `pom.xml` |
| for this component: |
| |
| [source,xml] |
| ---- |
| <dependency> |
| <groupId>org.apache.camel</groupId> |
| <artifactId>camel-webhook</artifactId> |
| <version>x.x.x</version> |
| <!-- use the same version as your Camel core version --> |
| </dependency> |
| ---- |
| |
| Typically, other components that support webhook will bring this dependency transitively. |
| |
| == URI Format |
| |
| ---- |
| webhook:endpoint[?options] |
| ---- |
| |
| |
| // component options: START |
| include::partial$component-configure-options.adoc[] |
| include::partial$component-endpoint-options.adoc[] |
| include::partial$component-endpoint-headers.adoc[] |
| // component options: END |
| |
| == Usage |
| |
| Put `webhook:` in front of the URI of a component that supports webhooks. |
| The options that start with `webhook` are for this component, and the other options are for the delegate endpoint. |
| |
| At startup, Camel exposes a REST endpoint for the webhook and registers its URL at the provider (`webhookAutoRegister`). |
| The provider must reach that URL, so set `webhookExternalUrl` to the public URL of your service. |
| Without it, the URL is made from the REST configuration of Camel, which the provider often cannot reach. |
| |
| [source,yaml] |
| ---- |
| - route: |
| from: |
| uri: webhook:telegram:bots |
| parameters: |
| authorizationToken: "{{telegram.token}}" |
| webhookExternalUrl: "https://camel.example.com" |
| webhookComponentName: platform-http |
| steps: |
| - to: |
| uri: log:info |
| ---- |
| |
| The REST endpoint uses a REST component of the application. When there is more than one, as with `camel run`, |
| set `webhookComponentName`, for example to `platform-http`. The path of the endpoint is `webhookPath`, or a hash of the |
| delegate URI, after `webhookBasePath` when it is set. |
| |
| The webhook options can also be set once on the component, for example in `application.properties`: |
| |
| [source,properties] |
| ---- |
| camel.component.webhook.webhook-external-url = https://camel.example.com |
| ---- |
| |
| == Examples |
| |
| Examples of the webhook component are provided in the documentation of the delegate components that support it. |