Using a community node (Mediastack) in your agent

Community Nodes allow you to extend your agent’s functionality with tools built by other developers. In this section, we’ll integrate the Mediastack Node, created by JunyaoC, to fetch live news.

Prerequisites

Before starting, ensure you have:

  1. A Mediastack API Key: Register an account at Mediastack to obtain your key.

  2. Familiarity with the Live News API: Refer to the Mediastack documentation for details on how the API works.

  3. This guide is a continued guide from Using ChatGPT node in your agent. Make sure you have go through the guide.


Step-by-Step Guide

The final agent are setup as below:

Agent setup with community node
1

Add the Mediastack Node

  1. Locate the Mediastack Node in the Community Nodes section of the Node Library.

  2. Drag the node into your workspace.

2

Configure the Mediastack Node

The Mediastack Node has several inputs for filtering news based on your requirements. For this example, we’ll filter for news from Malaysia.

  1. API Key:

    • Paste your Mediastack API key into the api_key field of the node.

  2. Country Filter:

    • Double-tap an empty space in the editor and type str.

    • Select Basic/String from the options and drag it to your workspace.

    • Enter the value my (country code for Malaysia) into the String node.

    • Connect this String node to the countries input of the Mediastack Node.

  3. Other Inputs:

    • If needed, you can use additional String nodes to specify filters like sources, categories, keywords, or languages.

    • For now, we’ll only filter by country.

3

Why Do We Need a JSON Stringify Node?

The Mediastack Node returns raw JSON data, which may not be easily readable or usable for downstream nodes like ChatGPT.

  • JSON Stringify converts this raw JSON data into a formatted string, making it compatible with nodes like ChatGPT for natural language processing.

  • It also ensures that any additional information can be passed in a structured and clean format.

To add the JSON Stringify Node:

  1. Drag it from the library under Basic/Format or use the double-click shortcut (explained below).

  2. Connect the result output of the Mediastack Node to the value input of the JSON Stringify Node.

4

Connect the Workflow

  1. Execution Flow (Exec):

    • Connect the exec output of the Input Node to the exec input of the Mediastack Node.

    • Link the exec output of the Mediastack Node to the JSON Stringify Node, and then to the ChatGPT Node.

    • Finally, connect the execution flow to the Output Node.

  2. Message/Data Flow:

    • Link the message output of the Input Node to the message input of the Mediastack Node.

    • Connect the result output of the Mediastack Node to the value input of the JSON Stringify Node.

    • Pass the output of the JSON Stringify Node to the message input of the ChatGPT Node.

    • Finally, link the response output of the ChatGPT Node to the Output Node.

5

Test Your Agent

  1. Use the Message Box to input a test message.

    • For example, type: “Fetch the latest news from Malaysia.”

  2. Observe the results:

    • The Mediastack Node fetches live news from Malaysia.

    • JSON Stringify formats the data.

    • ChatGPT processes and summarizes the news, which is returned to the Message Box.


Summary

  • Mediastack Node: Fetches live news with flexible filters.

  • String Nodes: Quickly assign values for filtering (e.g., country: my for Malaysia).

  • JSON Stringify Node: Converts raw data into a readable string format for ChatGPT.

  • Double-Click Shortcut: Saves time by skipping manual node selection from the library.

This guide empowers users to efficiently integrate a Community Node and optimize their workflow.

Last updated