ZekeSnider / Jared

An easily extensible chat bot for iMessage written in Swift.
Apache License 2.0
471 stars 52 forks source link
applescript chat-bot chatbot imessage swift

Build Status Carthage compatible Swift 5.0

Jared - An iMessage chat bot

Download Links

Please check out the release page for an up to date pre-compiled download.

What is Jared?

A powerful and easily extensible iMessage bot. It makes it possible to add chat bot features to any iMessage conversation. It includes some basic commands built in. API integrations, games, custom emotes, and much more can be added by using webhooks, the REST API, or by installing plugins.

Jared usage screenshot

Any pull requests and new GitHub issues are much appreciated! If you would like to develop a plugin for Jared, see the plugin section below. I'm always available on Twitter if you have any ideas/suggestions.

Installation

Jared Main Window

Jared must be run a machine running macOS with an active messages account logged in. It has only been tested on 10.14 Mojave and later. It may work on old versions of macOS but this is not guaranteed as there may have been changes to the message database's schema. If you don't want Jared posting as you, it is recommended that you create a new Apple ID and user account on your mac, and run it in the background under that user. That way it's not using your main Apple ID.

  1. Download Jared.app and move it to the applications folder.

See download section at the top.

  1. Run Jared.app, Allow Jared "Full Disk Access" in System Preferences.

This is required because of macOS permissions that limit access to the messages database.

  1. Grant access to automate Messages

If you are running macOS Catalina or later, you will need to allow Jared access to automate the message app. This allows Jared to send messages.

  1. (Optional) Allow contacts access

You can optionally allow Jared access to your contacts so that it can provide and update names of contacts. The contacts are used to set/retrieve names only.

  1. (Optional) Start REST API server

If you wish to use the REST API, you will need to enable it. If you have a firewall enabled on your mac, you will see a dialog prompting you to allow Jared access to the port it is binding.

Built in commands

For reference, here is a list of the commands built in to Jared. Because functionality can be added with plugins, the built in functionality is kept light.

Configuration

A configuration file is located at ~/Library/Application Support/Jared/config.json which allows you to:

See config-sample.json for an example.

Extensions

Jared Provides a variety of APIs to allow you to easily add your own commands, automate messages, and more. For all API documentation, see the documentation hub.

Plugins

Additional routes can be added via modularized plugins, written in native Swift code. Plugins are loaded dynamically from the ~/Library/Application Support/Jared/Plugins folder. To install a module, drag it in there and then send /reload to Jared, or click Reload Plugins in the UI.

For more information on developing your own plugins, see the plugin documentation. If you developed any plugins, please contact me a link so I can add a link here! I will be working on a few extra modules of my own as well, and will add them here when they are complete.

Webhooks

Jared supports webhooks for sending your server information about incoming and outgoing messages. Your server can respond to these requests to send messages, or use the REST API to send messages at any time. To configure webhooks, add them to the config.json mentioned above. For more info on the webhooks API, check out the webhook documentation.

REST API

Jared contains a web server with a REST API that can be enabled. This allows you make HTTP requests to send messages to any recipient. For more information, check out the REST API documentation.

How Jared works

Jared reads from the Messages database on a set interval and queries for new messages. It provides a routing framework for actioning on messages, and uses AppleScript to send outgoing messages. It's also multi-threaded so it can take care of multiple requests at once. Jared allows expansion via .bundle plugin files, webhooks, and a REST API. This allows commands to be added without modifying the main Jared code base.

I've tried using private APIs such as MessagesKit to send/receive messages to no avail so far. If you have any leads on this front I'd love to hear about it.