huginn / huginn

Create agents that monitor and act on your behalf. Your agents are standing by!
MIT License
43.21k stars 3.75k forks source link

Help - Web agent and pushover configuration #3133

Closed spencerskinner99 closed 2 years ago

spencerskinner99 commented 2 years ago

Hi,

This is a help/ feature suggestion thread.

Is it possible to have several web agents connected to a single pushover agent (and or slack agent too) such that when an event is produced by a web agent the url sent by the pushover agent is the url of that specific web agent.

Currently the only way I see of doing this is to make a pushover agent for every web agent, this seems excessive.

Many Thanks Spencer

Unending commented 2 years ago

You can send arbitrary data in your web agent event using the template option. If you want to set the URL dynamically to the scraped page you can use {{ _url_ }} or {{ _response_.url }} depending on your use case.

spencerskinner99 commented 2 years ago

Hi, I've given that a go but I am getting an error with my config which stops it saving.

When type is html or xml, all extractions must have a css or xpath attribute (bad extraction details for "template")

My config is below, sorry about the phone screenshot.

Screenshot_20220602-233935__01

Unending commented 2 years ago

The template isn't extracted and thus goes outside the extract option like this:

{
  "expected_update_period_in_days": "7",
  "url": "{{ url-e }}",
  "type": "html",
  "mode": "on_change",
  "extract": {
    "title": {
      "css": "h1",
      "value": "string(.)"
    },
  "template": {
    "url": "{{ _url_ }}"
  }
}
spencerskinner99 commented 2 years ago

Just managed to get that working, thank you very much!

Last quick question how would the url be embedded into a slack message

{
  "webhook_url": "xxx",
  "channel": "#123",
  "username": "Huginn",
  "message": "Site change",
  "icon": "",
  "url": "{{_url_}}"
}

This is currently how I have it and its not worked

Unending commented 2 years ago

I know the pushover API and huginn agent have a dedicated URL field. I'm not familiar with the slack API but you should just be able to add the URL to the message field using liquid formatting"message": "Site change: {{ url }}". If that's what you want, but it really depends on how the Slack API expects messages to be formatted.

spencerskinner99 commented 2 years ago

works a dream, thanks again!

frankdzh commented 2 years ago

unsubsribe

Unending @.***>于2022年6月3日 周五20:03写道:

The template isn't extracted and thus goes outside the extract option like this:

{ "expected_update_period_in_days": "7", "url": "{{ url-e }}", "type": "html", "mode": "on_change", "extract": { "title": { "css": "h1", "value": "string(.)" }, "template": { "url": "{{ url }}" } }

— Reply to this email directly, view it on GitHub https://github.com/huginn/huginn/issues/3133#issuecomment-1145892762, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHH7F5D2H24J5WDU5WBNKATVNHX7PANCNFSM5XTATDIQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>