How to set up outgoing HTTP requests

Configuring outgoing HTTP requests
HTTP Request
·
7/26/2023
·
5 min. read

General Information

HTTP Request serves as a mechanism for event notifications, allowing data to be transferred from one system to another. For instance, when a buyer leaves a comment, a notification about it appears in the client department's chat. Similarly, when a new order is received, you might need to calculate the delivery cost, or when a user's subscription is ending, a renewal task must be created for the CRM manager.

In all these examples, data transmission involves performing specific operations in the receiving system. This means that a particular function is invoked and the necessary parameters are passed to it. For example, if you want to create an appointment, you'll need the employee's ID for whom the appointment is scheduled, the date, time, contact details of the client, and, of course, the address of the function itself.

URL represents the address of the function that needs to be executed, and we pass the data to it. For example, the function to create a new contact could be located at http://example.com/nofollow/create/contact, while the function to update an order could be found at http://example.com/nofollow/update/order.

Request headers act as distinct markers for a request, enabling the receiving server to process it correctly. These headers might contain login and password information for authorization in the system where we are transferring the data. Different services may require their own unique headers for proper request processing.

Request body contains information about the event itself. It includes details like when it happened, which fields are filled in, and their corresponding values. The data is always presented as key-value pairs, where the "key" represents the field name and the "value" is its content. To set the keys correctly, it's essential to understand the expected object structure and data that the function requires. Objects can be simple or have nested forms, such as other objects and/or arrays. Objects are enclosed within curly braces: "{object}," while arrays are enclosed within square brackets: "[array]." To access keys from a simple object, you only need to specify their names. However, to access keys within nested objects, you should use "." to indicate the name of the child object and then the name of the key. Similarly, for nested arrays, instead of names, serial numbers starting with "0" are used to specify the desired array element.

Simple object:

Frame 1831.png

Object with nested object:

Frame 1832.png

Object with nested array and objects:

Frame 1833.png

No matter how the data is organized, when you send a request, there are different ways to package it. This is influenced by the request method and a necessary header called Content-type.

The two most common request methods are GET and POST. To simplify, think of GET as a postcard, where all the information is written on the outside next to the address. On the other hand, POST is like a regular letter that contains all the information inside.

In essence, when sending a request, you should have the URL of the function you're calling and the input it expects to receive. The data is written to the keys, and the key names should match the structure of the object the function expects. Don't forget to specify the Content-type and the method for the transmitted request. There are various combinations and variants of methods with data types that are possible. For all the necessary information about the required request settings, you can refer to the documentation of the receiving system.

Create a connection

Go to the Apps section and click on the Add a connection button.

HTTP request 4.png

Choose the HTTP request app and click the Add a connection button.

HTTP request 5.png

Fill in the HTTP Request fields.

HTTP request 10 (1).png

Name - specify any;

URL - is the domain of your CRM;

HTTP request parameters (request body) - parameters may differ depending on the action to be performed: for example, add a car or find it by VIN, create a new contact or service record (specified in request_type_id). A complete list of actions and the fields required for them can be obtained from autoCRM representatives;

Headers - specify the Authorization parameter;

Content-Type - JSON.

Filling in the fields when creating an automation:

HTTP request 6 (1).png

URL - leave empty, the URL specified in the App will be used;

Request method - POST;

User-Agent header - Mozilla/5.0 (compatible; Albato/1.0);

Authorization (header) - Basic, is the result of encoding the string "login: password" with the MIME base64 algorithm (for example, for the login "admin" and the password "password" will be "YWRtaW46cGFzc3dvcmQ=";

Parameters (last_name, first_name, phone, email, dealer_code, request_type_id, source_id) - fill in the parameters that we want to transfer to HTTP Request.

The HTTP Request connection provides perhaps the most flexible tool for transferring data. Depending on your goals, the implementation of the functionality may differ.

Setting up an incoming Webhook connection

A webhook is needed if there is no connection in Albato that you would like to use, then you can add this connection via the Incoming Webhook.

When creating a Webhook connection, you only need to specify the name (title) of the connection.

You can also specify parameters and headers if you know in advance how they are called in a third-party service. These parameters will appear in the automation.

HTTP request 7.png

After creation, you will have a Webhook URL, which you must put in a third-party service so that data is transmitted to us at a certain event.

HTTP request 8.png

The Catch a webhook button is needed for webhook connections, when you need to catch parameters from a third-party service in order to use them in the automation later.

HTTP request 9.png

HTTP request 10.png

All internal ID's can be obtained directly from your CRM, a description of this process is beyond the scope of this guide.

All given settings can be changed in the Automation builder.


HTTP Request
Webhook