Learn how to test your API in POSTMAN and configure it in Atom's HTTP requests
In this article, we will see in simple steps a use case in which an API connects to ATOM and the necessary configurations for this use case, using POSTMAN and the Atom's HTTP Request component. Let's get started!
Use Case
A company uses an internal system that registers its customers through a field called ID or identifier. This ID is unique for each customer and allows specific information requests. For this, the customer must log in with their username and password, which will be sent by email.
With this ID and through the "HTTP Request" component of Atom, both systems will be connected to request additional customer data, such as when they want to know their outstanding balance or the date of their next invoice.
When the customer interacts with a bot and requests this information, after the corresponding login by the customer, Atom sends a query to the internal system using the HTTP Request component, making use of this ID field.
These data are returned by the internal system to Atom and stored in the Save Response section of the HTTP component of the platform. In this way, the requested information is automatically available and updated so that, if the conversation is transferred to an agent, they can view the complete customer data without the need to make a new request.
It is important to note that, for this integration to work correctly, it is necessary to first verify that the API authentication of the internal system is configured and working properly.
For this, POSTMAN is used, where it is possible to validate access and test requests to the API. Once verified that the authentication was successful, the same authentication is configured in the "HTTP Request" component of Atom, allowing the flow of information to be continuous and without interruptions.
Atom only supports APIs that use the JSON data format for sending and receiving information.
If the documentation of an external system presents examples in other formats, such as XML or CSV, it will be necessary to perform a previous conversion to JSON before integrating it into Atom.
Connection Test with Postman
Before configuring the HTTP request, we can perform a test to verify that the authentication with our API is correct.
For this, we will perform a Basic Authentication test in Postman. For this test, it is necessary to have the username and password of the API.
If you want to know more about the different types of authentication in POSTMAN, read the corresponding article in the knowledge base.
To perform the authentication test, access POSTMAN.
In New Request, we will use the GET method, enter the URL of our API, and in the Authorization section, we will select Basic Auth, entering the corresponding username and password. Then, we click on Send to test.
Once the connection is successful, you will see the code 200 OK, as displayed on the screen, which means that the connection was successful.
In the BODY tab, look for the Authorization section and locate the token that was generated, which appears in quotes after the colon on the same line. This token will be used later to configure the headers of the HTTP Request component, where Authorization will be our Key, and in this case,
Basic cG9zdG1hbjpwYXNzd29yZA== will be the token used in the header of this connection.
Configuration in HTTP Request
We fill in the corresponding fields in the HTTP request as we will see below.
Within our bot, we access the HTTP Request component, clicking twice to view the fields in the right sidebar of the screen.
Here we will make the following configurations:
We will use the POST method and enter the URL of the API we will connect to.
In the body of the request, we will detail the fields that will be sent to the API with the ID of our customer.
As headers, we will use the corresponding Key and Token, as described in the previous step.
Important
Keep in mind that, in Postman, authentication is configured as Basic Authentication, specifying username and password. However, in the HTTP component of Atom, in the Header, it is only possible to specify a token.
This token can be generated by Postman itself or through a key generator, such as:
Then, in Save Response, considering that our customer wants to know the outstanding balance, we will save in the information fields SALDOPENDIENTE and FECHAPAGOSALDO the data from the API, specifically from the variables data.adeudo and data.fecha_limite.