Amazon Webhooks Overview (Beta)

Beta

Amazon EventBridge is a serverless event bus that distributes events to connect application components and build highly scalable and resilient event-driven applications. It offers a simple way to consume webhook events from the BigCommerce platform at scale.

To use Amazon EventBridge, you must do the following:

Prerequisites

  • To try out GraphQL queries and view responses, import our API examples into Postman or any other tool that allows testing of GraphQL queries.
  • Enter the following environment variables before starting:
CredentialsVariables
Store variableszone
store_hash
OAuth credentialsclient_id

Set up an event source (Not available in Beta)

Setting up an event source with EventBridge allows you to send event data to Amazon services directly instead of being responsible for receiving that traffic yourself through a front-end web server. You can set up an event source using a Create AWS Event Source query.

Example query: Create Amazon Event Source
POST https://{{zone}}/stores/{{store_hash}}/graphql
mutation createEventSource($input: CreateEventSourceInput!){
webhook {
createEventSource(input: $input) {
eventSource {
id
awsAccount
arn
eventSourceName
eventSourceRegion
}
}
}
}
GraphQL variables
{
"input" : {
"awsAccount": "649666292244",
"eventSourceName": "Final-Test-1",
"eventSourceRegion": "US_EAST_1",
"clientId": "4yk6pb824t53hirbuz5akdr652lpjb2"
}
}

Make note of the event_source_arn and event_source_name

Obtain the event_source_arn and event_source_name from the Graphql create event source mutation. You will not need them for the first iteration because there is no event source. After you create the event source, you will use these values later. You can save these fields in Postman as environment variables.

Associate an event bus (Not available in Beta)

The next step is to associate the event source with a bus. You can associate an event by following the procedure below:

Example query: Create an Amazon event bus
POST https://events.{{region}}.amazonaws.com/?Action=CreateEventBus&Version=2015-10-07
{
"EventSourceName": "{{event_source_name}}",
"Name": "{{event_source_name}}"
}

Create a rule (Not available in Beta)

Creating a rule helps to move specified events to the event bus otherwise, all events are ignored.

Example query: Create a rule
POST https://events.{{regions}}.amazonaws.com/?Action=PutRule&Version=2015-10-07
{
"Description": "Default rule to route all bigcommerce events.",
"EventBusName": "{{event_source_name}}",
"EventPattern": "{\"detail-type\":[\"bigCommerceWebhook\"]}",
"Name": "{{rule_name}}",
"State": "ENABLED"
}

Apply a target to the rule (Not available in Beta)

Add the specific targets to the specified rule. This step allows SQS to receive message requests and check end-to-end delivery.

Example query: Put Targets
POST https://events.{{regions}}.amazonaws.com/?Action=PutTargets&Version=2015-10-07
{
"EventBusName": "{{event_source_name}}",
"Rule": "{{rule_name}}",
"Targets": [
{
"Arn": "arn.aws:sqs:us-east-1:932486483912:{{sqs_name}}",
"Id": "{{sqs_id}}"
}
]
}

Create an Amazon EventBridge webhook

Using GraphQL to create an Amazon EventBridge webhoook.

Example query: Create Amazon EventBridge
POST https://{{zone}}/stores/{{store_hash}}/graphql
mutation createAwsEventBridgeWebhook($input: CreateEventBridgeWebhookInput!){
webhook {
createEventBridgeWebhook(input: $input) {
webhook {
id
scope
destination
isActive
createdAt
}
}
}
GraphQL variables
{
"input": {
"destination": "{{event_source_arn}}",
"isActive": true,
"scope": "store/category/updated"
}
}

Receive the event message (Not available in Beta)

The next step is to trigger the event to receive the event message. Although there is limited JSON support with the SQS API, you can use SQS Receive Messages to view the event message.