Automate Country Data Retrieval with GraphQL and Webhooks
detail.loadingPreview
Effortlessly fetch and format country-specific data using a powerful n8n workflow. This solution leverages GraphQL to query an external API and presents the information in a human-readable format triggered by a webhook.
About This Workflow
This n8n workflow provides a robust solution for retrieving detailed country information dynamically. It begins with a webhook that listens for incoming requests, capturing a country code from the query parameters. This code is then passed to a GraphQL node, which queries the countries.trevorblades.com API to fetch the country's name, phone code, and emoji. A subsequent function node parses the GraphQL response, extracting the relevant country data. Finally, a Set node formats this data into a user-friendly string, ready to be consumed by downstream applications or services. This workflow is ideal for applications needing real-time, accurate country details without manual intervention.
Key Features
- Dynamic Country Data Retrieval: Fetch specific country details like name, phone code, and emoji.
- GraphQL Integration: Seamlessly interact with GraphQL APIs for structured data.
- Webhook Trigger: Initiate data retrieval automatically via HTTP requests.
- Data Transformation: Clean and format raw API responses for usability.
- Extensible Workflow: Easily integrate into larger automation pipelines.
How To Use
- Set up the Webhook Node: Configure the
Webhooknode with your desired path (e.g.,/country-info). This node will act as the entry point for your workflow. - Configure the GraphQL Node: In the
GraphQLnode, set theendpointtohttps://countries.trevorblades.com/. For thequery, use the provided GraphQL query, ensuring the country code is dynamically pulled from the webhook's query parameters:query { country(code: "{{$node["Webhook"].data["query"]["code"].toUpperCase()}}") { name phone emoji } }. - Implement the Function Node: The
Functionnode's codeitems[0].json = JSON.parse(items[0].json.data).data.country; return items;parses the JSON response from the GraphQL API and extracts the country object. - Format the Output with the Set Node: In the
Setnode, define a new string value nameddata. Use an expression like=The country code of {{$node["Function"].data["name"]}} {{$node["Function"].data["emoji"]}} is {{$node["Function"].data["phone"]}}to format the retrieved country information.
Apps Used
Workflow JSON
{
"id": "3352a76b-2031-4611-abc9-0ceca6741240",
"name": "Automate Country Data Retrieval with GraphQL and Webhooks",
"nodes": 26,
"category": "DevOps",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 3352a76b-2031...
About the Author
Free n8n Workflows Official
System Admin
The official repository for verified enterprise-grade workflows.
Statistics
Related Workflows
Discover more workflows you might like
Automate Qualys Report Generation and Retrieval
Streamline your Qualys security reporting by automating the generation and retrieval of reports. This workflow ensures timely access to crucial security data without manual intervention.
Automated PR Merged QA Notifications
Streamline your QA process with this automated workflow that notifies your team upon successful Pull Request merges. Leverage AI and vector stores to enrich notifications and ensure seamless integration into your development pipeline.
Visualize Your n8n Workflows: Interactive Dashboard with Mermaid.js
Gain unparalleled visibility into your n8n automation landscape. This workflow transforms your n8n instance into a dynamic, interactive dashboard, leveraging Mermaid.js to visualize all your workflows in one accessible place.