ZekeSnider / Jared

An easily extensible chat bot for iMessage written in Swift.
Apache License 2.0
475 stars 52 forks source link

send to groups over REST API? #58

Closed jclin22009 closed 2 years ago

jclin22009 commented 2 years ago

Hi,

I've been playing with Jared, and it's completely awesome! One issue I'm running into is sending messages to groups. My request is formatted as: r = requests.post("http://localhost:3000/message",json={"body": {"message": message}, "recipient": {"handle": recipient_id}}) And I just set recipient_id to the iMessage id of the group (i.e. iMessage;+;chat238923983289). However, this does not seem to work. Would you recommend adding a field in the API request for participants, or using the webhook (I notice there is an example for group messaging on the webhooks section). Thank you!

ZekeSnider commented 2 years ago

Hi, the API should function as you're describing, but I think there's a bug in the handle comparison logic. The API should parse out if it's a group based on the handle format. If you're able to build from source could you try out this branch and let me know if that fixes it?

https://github.com/ZekeSnider/Jared/compare/zeke/fix-handle-comparison?expand=1

jclin22009 commented 2 years ago

I think it works, thank you!

ZekeSnider commented 2 years ago

Awesome, merged that into master!

simonwarchol commented 2 years ago

Do you mind creating a new release?

ZekeSnider commented 2 years ago

@simonwarchol yep, done! https://github.com/ZekeSnider/Jared/releases/tag/v1.5.4

saikarthikp9 commented 2 years ago

How do you find the iMessage ID of a group?

simonwarchol commented 2 years ago

/barf should give you the info you need :)

saikarthikp9 commented 2 years ago

I just don't want to send the /bark in that group chat. Is there another way?

jclin22009 commented 2 years ago

Another way is to enable the REST API and monitor the incoming chat messages (if someone sends something to the group) and copy the ID from there.

saikarthikp9 commented 2 years ago

Where exactly do I "monitor" this? Are logs stored somewhere? I've enabled REST APIs.

ZekeSnider commented 2 years ago

Check out the webhooks documentation, you can use a site like webhook.site to easily monitor requests. That will show you the content of messages including the group chat guid.