Connector SDK - External Webhooks Integration
TopicTopics usually cover more ground than other articles.
Author:
Fluent Commerce
Changed on:
13 Dec 2023
Author:
Fluent Commerce
Changed on:
13 Dec 2023
Author:
Fluent Commerce
Changed on:
13 Dec 2023

`/api/v1/fluent-connect/external-system/webhook`. When operated locally on port 8080, the URL becomes `localhost:8080/api/v1/fluent-connect/external-system/webhook`. When deployed elsewhere, the URL becomes `\/api/v1/fluent-connect/external-system/webhook`Author:
Fluent Commerce
Changed on:
13 Dec 2023
`connect-sdk-core-web-security` module: Connector Customization Guidelines`/api/v1/fluent-connect/external-system/webhook`. When operated locally on port `8080`1 security:
2 web:
3 publicEndpoints:
4 - "/actuator/**"
5 - "/api/docs"
6 - "/swagger-ui.html"
7 - "/api/v1/fluent-connect/webhook"
8 - "/api/v1/fluent-connect/scheduler/**"
9 customAuthFilters:
10 - "com.fluentcommerce.connect.core.web.security.filters.ApiKeyAuthenticationFilter"
11 - "com.fluentcommerce.connect.core.web.security.filters.FluentOauthTokenAuthenticationFilter"`/api/v1/fluent-connect/external-system/webhook`. When operated locally on port 8080, the URL becomes `http://localhost:8080/api/v1/fluent-connect/external-system/webhook`. Any request directed to this endpoint is automatically filtered and authenticated by `connect-sdk-core-web-security` module and placed in the event message queue. The webhook payload can be processed if the webhook’s request body: `route` property aligns with any of the "message handler" provided.Webhook Request:Header:Body:Below is the sample request body when calling the external webhook endpoint:`route`: The defined handler for handling the webhook request.`payload` : Data payload context that a defined Handler handles. The size limit for the `payload` data varies by the type of queue defined for the Connect SDK:1Authorization: <insert authorization value>
2fluent.account: <insert associated fluent account value>1{
2 "route" : "your-defined-handler-route",
3 "payload" : {
4 // props
5 }
6}1{
2 "route" : "fc.connect.sample-weather-update",
3 "payload": {
4 "id":"demo-weather",
5 "code":"300",
6 "temperature":"40",
7 "description":"Hot Day"
8 }
9}1@Component
2@HandlerInfo(name = "weather-update", route = "fc.connect.sample-weather-update")
3public class WeatherDataMessageHandler implements MessageHandler {
4 @Override
5 public void processMessage(@NotNull final MessageHandlerContext context) throws UnprocessableMessageException, HandlerRetryException {
6 UpsertSettingUtils.upsertSetting(getPayload(context), context, UpsertSettingUtils.FLUENT_SETTING_KEY);
7 }
8
9 protected WeatherData getPayload(final MessageHandlerContext context) {
10 // Extract data by defined Class `WeatherData`
11 final Optional<WeatherData> payload = context.getMessagePayload(WeatherData.class);
12 // Extract data by key-value
13 final Optional<Map> payload = context.getMessagePayload(Map.class);
14 // Handling optional data...
15 }
16}