1. Introduction
You can use external request actions to call third-party interfaces and use the responses from the actual interfaces to help you collect data or execute subsequent automated processes.
For example:
- Through external requests, visitor data (user name, mobile phone number, email address, and the last message sent by the visitor) is sent to the request URL to meet the data collection and analysis purposes of the third-party platform.
- Through external requests, specific data is returned and corresponding variables are generated. These variables can be used in the send message action to meet specific automated reply requirements.
What is an API interface?
API (Application Programming Interface) is an important part of the application. The interface is a tool that allows different software applications to communicate and exchange data with each other. The application provides an entry point for operating data. This entry point can be a function or class method, or a URL address or a network address. When the client calls this entry point, the application will execute the corresponding code operation to complete the corresponding function for the client.
HTTP request method:
HTTP methods refer to the methods defined in the standard HTTP protocol used for communication between clients and servers. These methods define how clients operate on server resources, thereby determining the behavior of the corresponding API interface. Common methods include:
- GET: Used to request the server to return a representation of a specific resource, usually used to obtain data. The GET method does not affect server resources and is safe and idempotent.
Suppose you are using a news reading app and you want to check today's news headlines. When you open the app and click the "Check News" button, the app sends a GET request to the server for today's news data. After receiving this GET request, the server returns data containing today's news headlines so that you can view it in the app.
-
POST: used to submit data to the server, often used to create new resources or perform non-idempotent operations. POST requests may change the state of the server or have side effects
Now suppose you want to post a comment in the same news reading app. When you are reading a piece of news, enter your comment in the comment box and click the "Post Comment" button. The app will send a POST request to the server to send your comment. After receiving the POST request, the server will save your comment to the database and return a response indicating that the comment was successfully posted.
-
PUT: used to update or replace resources to the server. It is usually used to completely replace a specified resource or create a new resource, but requires the client to provide a complete resource representation. PUT requests should be idempotent, that is, the results of multiple calls to the same PUT request should be consistent.
When you edit your profile, you may use the PUT method. For example, if you update your profile information (such as name, birthday, avatar, etc.) on a social media platform, when you click the "Save" button, the client will send a PUT request to the server to send the updated profile to the server, and the server will use this information to update your profile.
-
DELETE: used to request the server to delete the specified resource. It is often used to delete the specified resource. DELETE request should be idempotent, that is, the results of multiple calls to the same DELETE request should be consistent.
When you delete a post on a social media platform, you may use the DELETE method. When you click the "Delete" button, the client sends a DELETE request to the server, requesting the deletion of the specified post, and the server will delete the post and its related content.
Operation Process
1. Add external request action
Click the + sign on the right > click External Request Action > Finish adding.
2. Configure external requests
2.1 Configure the request URL (required)
- Click External Request to open the configuration window > Select the request method (POST, GET, DELETE) > Fill in the request URL as needed.
- As needed, you can add user data and call the request URL. Click the + sign > click the data you want to transfer > and complete the addition. (Optional)
2.2 Fill in the parameters Headers and Body required for the request URL (optional as needed)
- Add Headers or Body according to the request URL. Click Add > Fill in.
- Similarly, you can add user data. Click the + sign and select the corresponding user data as needed.
2.3 Test Request
You can test the content you just filled in to see if the call is successful or the callback data.
- Click Test Request to start the test.
- If the data returned is abnormal, you can modify the data, click Re-Request, and retest.
2.4 Using Response Mapping
- You can use the content returned by the external response, assign it to the corresponding variable, and use it in the send message action.
- Click Add > Enter the response content as required (must be filled in according to the JSON path format) > Fill in the corresponding variables in the message to be sent according to the corresponding variables displayed later, and the subsequent automatic sending of specific variable messages can be triggered.
Note: For the Json path format, please refer to https://goessner.net/articles/JsonPath/, which contains a sample introduction, as shown in Figure 2.
Frequently Asked Questions
1. Can I get the data of the entire data?
No, you can only get one of the items under data
2. In the automation process, can the branch be determined based on the return value of the external request according to the return value of {{FIELD_0}}?
Not supported yet. Currently, the return value of external requests only supports sending messages.