Article Overview:
This article will cover how you can achieve the following:
Set up webhooks in Virtuoso to notify external services about specific project events automatically.
Problem Statement:
How can we automatically notify external services when certain events happen in a project?
Solution:
Virtuoso offers a webhook feature that sends a POST request to specified URLs when specific events occur in a project.
This article covers the following topics:
- Creating a Webhook:
- Editing a Webhook
- Event Types
- Deliveries
- Payloads
Creating a Webhook:
- Go to the desired project.
-
Click on the Webhook Section.
- Click on New Webhook
- Fill out the following mandatory fields:
- Payload URL: URL to send POST requests (e.g., webhook. site).
- Content-Type: Choose application/JSON.
- Secret (optional): User-generated random token for verifying requests.
-
Description (optional): Virtuoso webhook notification.
Note: For this exercise, we will use https://webhook.site/ to generate a random URL, customers should replace this step with the URL where they would like to receive the notifications. Copy the Unique URL and paste it Into a Notepad file.
-
Choose events to trigger the webhook:
a. Send me everything (recommended).
b. Let me select individual events.
6. Click on Create.
Example of Creating Webhooks:
1. Go to the Webhooks tab in the respective project.
2. Fill in the mandatory fields and optional fields if needed.
3. Click Create.
4. After Webhook Creation, A ping event will automatically be triggered and notified at the payload URL.
5. When an execution event is triggered within the project, you will be notified at the payload URL.
Executing a journey:
Execution event: LAUNCHED
Execution event: STARTED
Execution event: FINISHED
Editing a webhook:
- Navigate to the Webhook section of a project.
- Click More and click the Edit option.
- The edit screen is identical to the creation screen.
- Update the webhook details as needed.
- Click on Save.
Event types:
The following table lists the webhook event types available:
Name | Description |
Execution |
Execution event:(such as LAUNCHED, STARTED, UPDATED or FINISHED). |
Ping |
An event is triggered automatically after the webhook creation to check if it was configured correctly. It can be re-triggered by choosing the Ping option in the project context menu |
Deliveries:
- Click the Down-arrow icon on a specific webhook in the management screen.
-
View additional details, including a list of successful and unsuccessful deliveries of the webhook notifications.
-
Each delivery has the following information:
-
Summary:
-
- UUID: A unique identifier of the delivery.
- Timestamp: The time when the request was made.
-
Duration: Time elapsed between sending the request and receiving the response.
-
Request information:
-
- Request headers: Includes URL, method, content type, and other headers.
- Payload: Sent in the POST request.
-
Response information (when Virtuoso receives a response from the payload delivery after contacting the provided URL)
- Response code: Status code received in the response;
- Response headers: All headers received back in the response;
-
Response body: Body content received in the response.
Payloads:
Event payloads include the event type, organisation, project, and sender (if a
user triggered the event).
Key | Type | Description |
type | string | PING or EXECUTION |
sender | object | Id, name, and email of the user who performed the event |
organization | object | Id and name of the organization |
project | object | Id and name of the project |
Execution event:
Key | Type | Description |
event | string | LAUNCHED, STARTED, UPDATED, or FINISHED |
execution | object | Information about the execution |
goal | object | Information about the related goal |
Execution Event Example:
{
"type": "EXECUTION",
"event": "LAUNCHED|STARTED|UPDATED|FINISHED",
"execution": { ... }, // the full execution details
"goal": { ... },
"sender": { ... },
"project": { ... },
"snapshot": { ... },
"organization": { ... }
}
Ping event:
Key | Type | Description |
hook_id | integer | The ID of the webhook that triggered the ping |
hook | object | The webhook configuration |
Ping Event Example:
{
"type": "PING",
"sender": {...},
"organization": {...},
"project": {...},
"webhookId": XXXX,
"webhook": {...}
}
Comments
0 comments
Please sign in to leave a comment.