ZIP Code Lookup
In this example, we will demonstrate how to structure an automatic query using the Execute JavaScript functionality to consume the Zipcodebase API. The goal is to interact with the client, collect and validate the provided ZIP Code, perform the query, and deliver the corresponding address in a dynamic and automated way.
Example Using the Zipcodebase
-
First, it is necessary to use the Conversation Created (WhatsApp) trigger in the automation and validate the response to save the provided ZIP Code value in the variable
payload.zip
. -
Once the ZIP Code is provided, our system automatically saves the received value (ZIP Code number) in the variable
payload.zip
. -
Next, we use Execute JavaScript to make a request to the Zipcodebase API and retrieve the corresponding address, as shown in the code below:
- If the request fails, the code encounters issues, or the provided ZIP Code is incorrect, we can use Execute JavaScript to handle the error by creating an informative message with options to restart the query.
- If the request is successful, a confirmation message with the address corresponding to the ZIP Code will be sent. In this message, we also use button options to either direct the conversation to an agent or to finalize the confirmation process.
Observations:
- To learn more about the advanced settings of our WhatsApp messages, access our article in the help center: Understanding the Logic, Time, Chat, and Advanced Actions in Automations
- To learn more about structuring WhatsApp messages, automations, and using buttons, check out our tutorials:
- Automations: https://reportana.com/help/category/automations
- WhatsApp Marketing: https://reportana.com/help/category/whatsapp-marketing
- Messages with Buttons: https://reportana.com/help/article/how-to-create-whatsapp-messages-with-buttons
- To check the Zipcodebase API, access the official documentation: https://zipcodebase.com/