It consumes HTTP resources from SHIMLI streams, using an API that returns responses in JSON format.
- Prerequisites: You need an account with an active SHIMLI instance and an API that returns responses in JSON format. The example uses a free API called SWAPI to access Star Wars data.
- User Interaction: Through WhatsApp, the user receives a list of options to query, such as Star Wars characters, planets and spaceships. This is done through a message type control with lists.
- Wait for User Response: A "Wait for a response" type control is used to wait for the user's response and store it in a variable during the flow.
- Response Processing: A "Branch" type control filters and compares the user's response to determine the flow of the conversation.
- Use of the Fetch Variables Control: This control allows you to make calls to an API and store the server's response in variables.
- Response to User: If the response from the server is successful, a message with buttons is sent to the user, showing the number of characters and allowing to select for more information.
- Character Information Query: When a character is selected, the API is queried with the selected character code, and the API responds with all the character's characteristics in JSON format.
- Information Storage: Information is stored in variables with the same name as in the JSON object, accessing only properties at the root of the object.
- End Flow: An "End Flow" control is added to indicate that the conversation has ended.
- Testing the Flow: Finally, the flow is tested by starting a conversation in WhatsApp with the instance connected to SHIMLI, selecting the characters option and receiving the corresponding information.