hedwig-im / hedwig

An Adapter-based Bot Framework for Elixir Applications
MIT License
656 stars 73 forks source link

How to actively send messages? #34

Closed derhackler closed 8 years ago

derhackler commented 8 years ago

Hi,

I'm currently trying to build an agent, that is supposed to actively send messages to a HipChat room when certain EC2 instances are running that shouldn't run.

Replying works fine (in the responders), but how can I send a message via the agent actively? I tried:

Hedwig.Robot.send(pid, %{text: "hello world"})

This crashes my agent with a match error.

Best, Benedikt

jwarlander commented 8 years ago

You'll have to give it a %Hedwig.Message{} struct; the below works fine for me:

msg = %Hedwig.Message{
  type: "groupchat",
  room: "some_room_jid",
  text: "hello world"
}
Databot.Robot.send(pid, msg)
scrogson commented 8 years ago

Thanks for answering @jwarlander!

@derhackler let me know if this doesn't solve your issue.

derhackler commented 8 years ago

Works perfectly! Thanks @jwarlander!

jwarlander commented 8 years ago

I documented this at work just a few days ago, so the information was already at my fingertips.. ;)