Usage example ‐ Amazon (UK) Product Monitoring - huginn/huginn GitHub Wiki
Brief
This is an example of using the Huginn automation system to monitor the price of printer ink cartridges on the Amazon website.
Use Case:
You want to keep track of the price of a specific printer ink cartridge on Amazon UK and receive notifications when the price drops below a certain threshold.
Components
- Website Agent: Periodically checks price and color information, and stores the results as events.
- Email Agent: Sends notifications when events are received.
- Trigger Agent: Monitors price events and triggers new events when the price falls below a threshold.
- Formatter Agent: Formats event output to generate more user-friendly messages.
Applicable to other websites
- US website: Update links and currency symbols, as well as color spellings
- German website: Update links, replace
"£"with"EUR "
JSON
{
"schema_version": 1,
"name": "Amazon Toner",
"description": "No description provided",
"source_url": false,
"guid": "937f937533d4a490a02781381a763bf3",
"tag_fg_color": "#ffffff",
"tag_bg_color": "#5bc0de",
"icon": "gear",
"exported_at": "2016-10-03T16:58:25Z",
"agents": [
{
"type": "Agents::EmailAgent",
"name": "Amazon Toner Email Agent",
"disabled": false,
"guid": "230a06d95b01efcbd24f4f7b332506dc",
"options": {
"subject": "Amazon Toner On Sale",
"headline": "",
"expected_receive_period_in_days": "90",
"body": "{{body_text}}"
},
"propagate_immediately": true
},
{
"type": "Agents::WebsiteAgent",
"name": "Amazon Toner Website Agent",
"disabled": false,
"guid": "2c1ea904fea73164ac69fe5ba657a5db",
"options": {
"expected_update_period_in_days": "90",
"url": [
"https://www.amazon.co.uk/..."
],
"type": "html",
"mode": "on_change",
"extract": {
"body_text": {
"xpath": "//*[@id=\"priceblock_ourprice\"]",
"value": "substring-after(.,\"£\")"
},
"url": {
"xpath": "//link[@rel='canonical']/@href",
"value": "."
},
"color": {
"xpath": "//*[@id=\"variation_color_name\"]/div/span",
"value": "normalize-space(.)"
}
}
},
"schedule": "every_1h",
"keep_events_for": 0,
"propagate_immediately": true
},
{
"type": "Agents::WebsiteAgent",
"name": "Amazon Toner Website Agent Yellow",
"disabled": false,
"guid": "e7e4f3cfde6a14cbf8e7ec6ab6570772",
"options": {
"expected_update_period_in_days": "90",
"url": [
"https://www.amazon.co.uk/..."
],
"type": "html",
"mode": "on_change",
"extract": {
"body_text": {
"xpath": "//*[@id=\"priceblock_ourprice\"]",
"value": "substring-after(.,\"£\")"
},
"url": {
"xpath": "//link[@rel='canonical']/@href",
"value": "."
},
"color": {
"xpath": "//*[@id=\"prodDetails\"]/div/div[1]/div/div[2]/div/div/table/tbody/tr[5]/td[2]",
"value": "normalize-space(.)"
}
}
},
"schedule": "every_1h",
"keep_events_for": 0,
"propagate_immediately": true
},
{
"type": "Agents::TriggerAgent",
"name": "Amazon Toner Trigger Agent",
"disabled": false,
"guid": "eaf805c6260c26c948bf291608e2ceb5",
"options": {
"expected_receive_period_in_days": "1",
"keep_event": "false",
"rules": [
{
"type": "field<value",
"value": "99",
"path": "body_text"
}
],
"message": "{{agent}} toner on sale for {{body_text}}. <a href=\"{{url}}\">{{url}}</a>"
},
"keep_events_for": 0,
"propagate_immediately": true
},
{
"type": "Agents::EventFormattingAgent",
"name": "Amazon Toner Formatting",
"disabled": false,
"guid": "f3b7087e155ec7d9c4a5898d06f33615",
"options": {
"instructions": {
"message": "Amazon Toner On Sale",
"agent": "{{color}}",
"subject": "{{body_text}}",
"body_text": "{{body_text}}",
"url": "{{url}}"
},
"matchers": [
],
"mode": "clean"
},
"keep_events_for": 0,
"propagate_immediately": true
}
],
"links": [
{
"source": 1,
"receiver": 4
},
{
"source": 2,
"receiver": 4
},
{
"source": 3,
"receiver": 0
},
{
"source": 4,
"receiver": 3
}
],
"control_links": [
]
}