Project

mural-ruby

0.0
The project is in a healthy, maintained state
Ruby library for the Mural public API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 2.7
 Project Readme

Mural Ruby

GitHub Actions Workflow Status Gem Version GitHub License

Ruby library for the Mural public API.

Disclaimer

The views and opinions expressed in this repository are solely hose of the individual contributors and do not represent the official view of Tactivos, Inc. d/b/a Mural.

Mural does not endorse this repository in any way.

Installation

git checkout https://github.com/mickaelpham/mural-ruby
cd mural-ruby
bundle install

Authorization

  1. Register a new app and gather your client_id and client_secret. For the scopes, pick the minimum required for your application.

  2. Create a .env file with the following template and fill in MURAL_CLIENT_ID and MURAL_CLIENT_SECRET with those values:

MURAL_CLIENT_ID=
MURAL_CLIENT_SECRET=
MURAL_SCOPE=
MURAL_REDIRECT_URI=http://localhost:4567/callback
MURAL_HOST=app.mural.co
  1. Run the script to request your access and refresh tokens:
bin/authorize
  1. Start the console:
bin/console
  1. From the console, create a client instance and start using it, e.g.:
irb(main):001> mural = Mural::Client.from_env
=>
#<Mural::Client:0x0000000120baa740
...
irb(main):002> mural.users.current_user
=>
#<Mural::CurrentUser:0x0000000124614bd8
 @avatar="<AVATAR_URL>",
 @company_id=nil,
 @company_name=nil,
 @created_on=1753301275000,
 @email="<USER_EMAIL>",
 @first_name="<USER_FIRST_NAME>",
 @id="=<USER_ID>",
 @last_active_workspace="<USER_WORKSPACE>",
 @last_name="<USER_LAST_NAME>",
 @type="member">

Usage

Upload a file to a mural

To upload a my.pdf file that's located in the same directory as where you are running the script:

MURAL_ID = 'workspace-1.mural-1'

client = Mural::Client.from_env

# Create an asset, receive an URL to upload the content to.
asset = client.mural_content.create_asset(
  MURAL_ID,
  file_extension: 'pdf',
  asset_type: 'file'
)

# Upload the asset to the received URL.
request = Net::HTTP::Put.new(uri)
request['x-ms-blob-type'] = asset.headers.blob_type

path = File.expand_path('./my.pdf', __dir__)
request.body = File.read(path)

Net::HTTP.start(
  uri.hostname, uri.port, use_ssl: uri.scheme == 'https'
) do |http|
  http.request request
end

# Create a `file` widget on the mural to display the asset preview.
params = Mural::Widget::CreateFileParams.new.tap do |params|
  params.name = asset.name
  params.x = 250
  params.y = 0
end

client.mural_content.create_file(MURAL_ID, params)

Mentioning someone in a comment

  • You can reply to a comment by passing a replies array of String message. Each message will be added as a reply to the original comment.
  • You can "[at] mention" someone in a comment or in a reply by using the following pattern in the message or the replies:
@[<USER FULL NAME> @<USER ID>](<USER ID>)

Example replying to a thread:

MURAL_ID = 'mural-1'
COMMENT_ID = 'comment-1'

reply_to_params = Mural::Widget::UpdateCommentParams.new.tap do |c|
  c.replies = ["Can you have a look @[John Doe @user-1](user-1)]?"]
end

client.mural_content.update_comment(MURAL_ID, COMMENT_ID, reply_to_params)

comment thread

Note that the user must already be a mural member for the mention to trigger an email notification.

comment email notification

Known limitations

  • DrawWidget, AKA sketches, are not returned by the GET widgets endpoint.

draw widget example

  • Similarly, InkingWidget, AKA drawings, are not returned by the endpoint.

inking widget example

  • Mind maps are smart widgets, they are simply a collection of text and arrow widgets. There are no specific type for a mind map in the API.

mind map example

  • Likewise, smart planners are collection of widgets, and the API doesn't specify anything about them.

smart planner example