|
| 1 | +# @elizaos/plugin-news |
| 2 | + |
| 3 | +A plugin for fetching and handling real-time news data through NewsAPI integration. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This plugin provides functionality to: |
| 8 | +- Fetch latest news articles from NewsAPI |
| 9 | +- Search news by specific topics or keywords |
| 10 | +- Get article summaries including titles, descriptions, and URLs |
| 11 | +- Limit results to most recent and relevant content |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +```bash |
| 16 | +npm install @elizaos/plugin-news |
| 17 | +``` |
| 18 | + |
| 19 | +## Configuration |
| 20 | + |
| 21 | +The plugin requires the following environment variable: |
| 22 | + |
| 23 | +```env |
| 24 | +NEWS_API_KEY=your_newsapi_key # Required for accessing NewsAPI |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +Import and register the plugin in your Eliza configuration: |
| 30 | + |
| 31 | +```typescript |
| 32 | +import { newsPlugin } from "@elizaos/plugin-news"; |
| 33 | + |
| 34 | +export default { |
| 35 | + plugins: [newsPlugin], |
| 36 | + // ... other configuration |
| 37 | +}; |
| 38 | +``` |
| 39 | + |
| 40 | +## Features |
| 41 | + |
| 42 | +### Current News Action |
| 43 | + |
| 44 | +The plugin provides a `CURRENT_NEWS` action that responds to various news-related queries: |
| 45 | + |
| 46 | +```typescript |
| 47 | +// Example queries the action responds to: |
| 48 | +"what's the latest news about <searchTerm>?" |
| 49 | +"can you show me the latest news about <searchTerm>?" |
| 50 | +"what's in the <searchTerm> news today?" |
| 51 | +"show me current events about <searchTerm>?" |
| 52 | +"what's going on in the world of <searchTerm>?" |
| 53 | +"give me the latest headlines about <searchTerm>?" |
| 54 | +"show me news updates about <searchTerm>?" |
| 55 | +"what are today's top stories about <searchTerm>?" |
| 56 | +``` |
| 57 | + |
| 58 | +The action returns up to 5 recent articles, including: |
| 59 | +- Article title |
| 60 | +- Description |
| 61 | +- URL |
| 62 | +- Content preview (up to 1000 characters) |
| 63 | + |
| 64 | +## Development |
| 65 | + |
| 66 | +### Building |
| 67 | + |
| 68 | +```bash |
| 69 | +npm run build |
| 70 | +``` |
| 71 | + |
| 72 | +### Development Mode |
| 73 | + |
| 74 | +```bash |
| 75 | +npm run dev |
| 76 | +``` |
| 77 | + |
| 78 | +### Linting |
| 79 | + |
| 80 | +```bash |
| 81 | +npm run lint |
| 82 | +``` |
| 83 | + |
| 84 | +### Project Structure |
| 85 | + |
| 86 | +``` |
| 87 | +plugin-news/ |
| 88 | +├── src/ |
| 89 | +│ ├── actions/ # Action implementations |
| 90 | +│ │ ├── news.ts # Current news action |
| 91 | +│ │ └── index.ts # Action exports |
| 92 | +│ └── index.ts # Main plugin export |
| 93 | +├── package.json |
| 94 | +└── tsconfig.json |
| 95 | +``` |
| 96 | + |
| 97 | +## Dependencies |
| 98 | + |
| 99 | +- `@ai16z/eliza`: Core Eliza framework |
| 100 | +- `tsup`: Build tool for TypeScript packages |
| 101 | +- Other standard dependencies listed in package.json |
| 102 | + |
| 103 | +## API Reference |
| 104 | + |
| 105 | +### Actions |
| 106 | + |
| 107 | +- `CURRENT_NEWS`: Main action for fetching news |
| 108 | + - Aliases: `["NEWS", "GET_NEWS", "GET_CURRENT_NEWS"]` |
| 109 | + - Automatically extracts search terms from user messages |
| 110 | + - Returns formatted news articles with titles, descriptions, and URLs |
| 111 | + |
| 112 | +### Response Format |
| 113 | + |
| 114 | +```typescript |
| 115 | +interface NewsResponse { |
| 116 | + title: string; |
| 117 | + description: string; |
| 118 | + url: string; |
| 119 | + content: string; // Limited to 1000 characters |
| 120 | +} |
| 121 | +``` |
| 122 | + |
| 123 | +## Future Enhancements |
| 124 | + |
| 125 | +1. **Additional News Sources** |
| 126 | + - Integration with multiple news APIs |
| 127 | + - RSS feed support |
| 128 | + - Social media news aggregation |
| 129 | + |
| 130 | +2. **Content Analysis** |
| 131 | + - Sentiment analysis of news articles |
| 132 | + - Topic categorization |
| 133 | + - Trend detection |
| 134 | + - Fact-checking integration |
| 135 | + |
| 136 | +3. **Customization Options** |
| 137 | + - User preferences for news sources |
| 138 | + - Custom filtering rules |
| 139 | + - Personalized news feeds |
| 140 | + - Language preferences |
| 141 | + |
| 142 | +4. **Advanced Search** |
| 143 | + - Date range filtering |
| 144 | + - Source filtering |
| 145 | + - Category-based search |
| 146 | + - Advanced query syntax |
| 147 | + |
| 148 | +5. **Performance Improvements** |
| 149 | + - Caching layer |
| 150 | + - Rate limiting optimization |
| 151 | + - Response compression |
| 152 | + - Batch processing |
| 153 | + |
| 154 | +We welcome community feedback and contributions to help prioritize these enhancements. |
| 155 | + |
| 156 | +## Contributing |
| 157 | + |
| 158 | +Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information. |
| 159 | + |
| 160 | + |
| 161 | +## License |
| 162 | + |
| 163 | +This plugin is part of the Eliza project. See the main project repository for license information. |
| 164 | + |
| 165 | +## Credits |
| 166 | + |
| 167 | +This plugin integrates with and builds upon several key technologies: |
| 168 | + |
| 169 | +- [NewsAPI](https://newsapi.org/): News data provider |
| 170 | + |
| 171 | +Plugin generated from Eliza coding tutorial [Agent Dev School Part 2](https://www.youtube.com/watch?v=XenGeAcPAQo) |
0 commit comments