LogoLogo
CommunitySupport PortalYouTubeStart a free trial
  • Welcome
  • Commerce Engine
  • Orchestration Engine
  • API Documentation
  • Release Notes
  • Changelog
  • Commerce Engine
  • Getting Started
    • General Concepts of Emporix
    • Creating your first tenant
    • Developer Portal
      • Manage Users
      • Manage API Keys
      • Tenant List
      • My Account
      • Manage Showcase and Sample Data
  • Customer Use Cases
    • Commerce Use Cases
      • Quote Process
      • Orders
      • Coupons and Redeeming Rewards
      • Returns
      • Payments
      • User Management and Approvals
      • Customer Social Login
      • Personalized Commerce - Customer Segments
      • Company Shared Orders and Customer Groups
    • Automated Use Cases
      • First Registration Coupon
      • Availability and Warehouse Assignment
      • Quote and Order Entry Automation
  • System Management
    • Introduction
    • Authentication and Authorization
      • Identity and Access Management (IAM)
      • Auth0
      • Emporix Single Sign-On (SSO)
    • Webhook Event Publishing
      • HTTP Webhook Strategy - HMAC Configuration
      • HTTP Webhook Strategy - Integration with Azure Service Bus
      • HTTP Webhook Strategy - Integration with Amazon Simple Queue Service (SQS)
    • Search
      • Universal Search Connector
      • Search Configuration
      • Indexing Service
    • Optimistic Locking
  • Extensibility and Integrations
    • Extensibility Cases
      • External Products, Pricing and Fees
      • Enabling Custom Extensions
    • Integrations
      • SAP Integration
    • Payment Systems
      • PayPal
      • Saferpay
      • Spreedly Gateway
      • Unzer
    • Third Party Add-Ons
      • Emporix Contentful App
      • Emporix Builder.io Plugin
      • Magnolia Emporix Connector
      • Zendesk Emporix Connect
    • Powered by AI
      • AI Smart Config
      • AI Smart Import
  • Core Commerce
    • Introduction
    • AI Assistance
    • Carts
    • Catalogs
    • Categories
    • Coupons
    • Customer Management
      • Approvals
      • Assisted Buying
      • Customer Groups
      • Customer Segments
    • Data Localization
    • Delivery Cycle Management
    • Mixin Schemas
    • Media Management
    • Orders
      • Shared Orders
    • Pricing
      • Pricing (Legacy)
    • Products
      • Availability, location, and stock levels
      • Brands
      • Labels
    • Quotes
    • Returns
    • Reward Points Management
    • Sites
    • Tax Classes
      • Tax classes (Legacy)
    • Measurement Units
  • Management Dashboard
    • Introduction
    • Customer Management
      • Companies
      • Customers
      • Groups
      • Segments
      • Coupons
    • Quotes
      • Quotes
      • Status Codes
    • Orders
      • Orders
      • SEPA
      • Returns
    • Catalogs
      • Catalogs
      • Categories
    • Products
      • Products
      • Product Templates
      • Labels
      • Suppliers
      • Brands
      • AI for a Product Description
    • Pricing
      • Price Models
      • Price Lists
    • Settings
      • Sites
      • Shipping Zones and Methods
      • Delivery Times
      • Units
      • Tax
      • Countries
      • Currencies
      • Languages
      • System Preferences
      • Custom Entities
      • Mixin Schemas
    • Administration
      • Users and Groups
      • Extensions
      • API Statistics
      • Webhooks
    • Extensions
    • Custom Instances
  • Additional Resources
    • Glossary
    • Videos
    • Emporix Community
Powered by GitBook
LogoLogo

Resources

  • Emporix.com
  • Developer Policy
  • Terms of Use

Find us

  • LinkedIn

© 2025 Emporix. All Rights Reserved.

On this page
  • Preparing Amazon infrastructure
  • Amazon Simple Queue Service (SQS)
  • Secret key
  • Amazon Lambda
  • API Gateway
  • Configuring Emporix webhooks
  • Creating product

Was this helpful?

Export as PDF
  1. System Management
  2. Webhook Event Publishing

HTTP Webhook Strategy - Integration with Amazon Simple Queue Service (SQS)

See the example of integration Amazon Simple Queue Service through webhooks.

Thanks to HTTP webhook strategy, you can choose the event service that enables communication between Emporix and external systems. This article demonstrates how you can connect Amazon Simple Queue Service to receive events notifications from Emporix. Follow the steps to set up the connection on both sides. Adjust the actual implementation to your needs. Amazon Simple Queue Service (SQS) is a service that allows for sending, storing, and receiving messages between distributed systems. As such, you can choose it as one of the solutions to connect Emporix with some other systems in your company through the webhooks functionality.

Preparing Amazon infrastructure

The integration between Emporix and Amazon Simple Queue Service in this example will use Amazon Lambda that is able to receive the HTTP request, validate HMAC signature and then send the request body to the specified queue.

Amazon Simple Queue Service (SQS)

To create SQS, go to the AWS Management Console.

Follow the steps described in the AWS documentation Creating an Amazon SQS standard queue and sending a message.

  1. Create a queue called webhooks and use the default settings.

  2. Save the URL value of your queue, which you can see in the Details section. This is later required in the Lambda code.

Secret key

  1. Create a Secret Key that is required in the later steps to set up the connection between Lambda and SQS.

Follow the steps described in the AWS documentation Where’s My Secret Access Key?

  1. Save the Access Key Id and Secret Key values to provide them later in the Lambda code.

Amazon Lambda

  1. Create a Lambda function called webhookFun.

Follow the steps described in the AWS documentation Run a Serverless "Hello, World!" with AWS Lambda.

The function uses NodeJS 16 and JavaScript.

  1. Modify the function's code to provide necessary details in the placeholders:

const AWS = require('aws-sdk');
const crypto = require('crypto');

// i
AWS.config.update({
  region: 'eu-north-1',
  accessKeyId: 'FILL_IT',
  secretAccessKey: 'FILL_IT',
});

const sqs = new AWS.SQS();

const secretKey = 'password123'; // ii

exports.handler = async (event, context) => {

  console.log(event);
  const body = JSON.stringify(event.body);
  const hmac = crypto.createHmac('sha256', secretKey);
  hmac.update(body);

  const computedHmac = hmac.digest('base64');
  
  if (computedHmac !== event.headers['emporix-event-signature']) {
    return {
      statusCode: 401,
      body: JSON.stringify("HMAC validation didn't pass."),
    };
  }
  
  try { // iii
    const messageParams = {
      MessageBody: body,
      QueueUrl: 'queue-url',
    };

    await sqs.sendMessage(messageParams).promise();

    return {
      statusCode: 200,
      body: JSON.stringify('The message was sent to SQS queue.'),
    };
  } catch (error) {
    console.error('Error:', error);
    return {
      statusCode: 500,
      body: JSON.stringify('An error occured during sending message to SQS queue.'),
    };
  }
};

Pay attention to the marked lines:

i. AWS.config - define relevant values to the following properties: region, accessKeyId and secretAccessKey.

ii. secretKey constant - provide the secret phrase for HMAC validation. You need to specify the same value in the webhooks HTTP configuration in the later steps. Here, we defined it as password123.

Find more information on how to configure HMAC validation in HTTP Webhook Strategy - HMAC Configuration.

iii. when HMAC validation passes, the message body is sent with the request to the queue. Provide the QueueUrl which points to your queue.

  1. Deploy the modified function.

API Gateway

To fully prepare Amazon's part, API Gateway is required so that it triggers the Lambda through HTTP requests.

  1. Create an API Gateway of an HTTP API type.

Follow the steps described in the AWS documentation Create an HTTP API.

a. In the Integrations section, point to your Lambda.

b. For the API name, choose webhooks.

c. In Routes, create a POST route.

  1. Deploy the API Gateway and save the url to your function. It will be needed while defining webhooks HTTP configuration on Emporix side.

Configuring Emporix webhooks

Now, prepare Commerce Engine.

  1. Configure webhooks to send the events as HTTP POST requests. Use the following curl and provide relevant information in the placeholders:

curl -L 'https://api.emporix.io/webhook/{{tenant}}/config' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{token}}' \
-d '{
    "code": "http",
    "active": true,
    "provider": "HTTP",
    "configuration": {
        "secretKey": "password123",
        "destinationUrl": "{{destinationUrl}}"
    }
}'

Placeholders to fill in:

  • tenant - name of your production tenant

  • token - your generated Emporix access token with relevant scopes

  • destinationUrl - link to your API Gateway

  1. Subscribe to a chosen event. In this example, we subscribe to the product creation event (remember to replace the values in the placeholders):

curl -L -X PATCH 'https://api.emporix.io/webhook/{{tenant}}/event-subscriptions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{token}}' \
-d '[
  {
    "eventType": "product.created",
    "action": "SUBSCRIBE",
    "fieldsToSubscribe": [
      "name"
    ],
    "fieldsToUnsubscribe": [
      "description"
    ]
  }
]
 '

Creating product

The integration is ready. To see it in action, let's create a product.

Create a product with the following curl request providing your relevant details in the placeholders:

curl -L 'https://api.emporix.io/product/{{tenant}}/products/' \
-H 'Content-Language: en' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{token}}' \
-d '{
    "name": "Test product for documentation",
    "code": "unique",
    "description": "product description",
    "published": false
}'

After the product is created the event is sent. The webhook service consumes the event and sends it as HTTP request to the specified destinationUrl, which is the API Gateway. Then, the Lambda function receives the request and sends it to Amazon Simple Queue Service (SQS).

PreviousHTTP Webhook Strategy - Integration with Azure Service BusNextSearch

Last updated 1 month ago

Was this helpful?