{"id":13878737,"url":"https://github.com/Qurasoft/teams_connector","last_synced_at":"2025-07-16T14:32:48.665Z","repository":{"id":59157387,"uuid":"426945283","full_name":"Qurasoft/teams_connector","owner":"Qurasoft","description":"Publish Cards to your Microsoft Teams channels directly from Ruby.","archived":false,"fork":false,"pushed_at":"2023-12-01T15:57:32.000Z","size":48,"stargazers_count":18,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-03T20:45:10.955Z","etag":null,"topics":["connector","messaging","microsoft-teams","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Qurasoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-11-11T09:39:12.000Z","updated_at":"2023-05-12T16:35:31.000Z","dependencies_parsed_at":"2024-01-13T20:38:55.441Z","dependency_job_id":"c33166f8-b4b0-4a8d-9b0b-aecff0c454ea","html_url":"https://github.com/Qurasoft/teams_connector","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":0.2941176470588235,"last_synced_commit":"9bc13492a5ac275b07df2c195511afe70dfd6995"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/Qurasoft/teams_connector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qurasoft%2Fteams_connector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qurasoft%2Fteams_connector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qurasoft%2Fteams_connector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qurasoft%2Fteams_connector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Qurasoft","download_url":"https://codeload.github.com/Qurasoft/teams_connector/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Qurasoft%2Fteams_connector/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265325938,"owners_count":23747419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["connector","messaging","microsoft-teams","rails","ruby"],"created_at":"2024-08-06T08:01:58.219Z","updated_at":"2025-07-16T14:32:48.302Z","avatar_url":"https://github.com/Qurasoft.png","language":"Ruby","readme":"# Teams Connector\n\n[![Gem Version](https://badge.fury.io/rb/teams_connector.svg)](https://badge.fury.io/rb/teams_connector)\n![RSpec](https://github.com/qurasoft/teams_connector/actions/workflows/ruby.yml/badge.svg)\n\nWelcome to Teams Connector. This gem allows you to easily send messages from your ruby project to Microsoft Teams channels.\nIt integrates in your rails project, when you are using bundler or even in plain ruby projects.\n\nThe messages can be send synchronous or asynchronous with [Sidekiq](https://github.com/mperham/sidekiq). \n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'teams_connector'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install teams_connector\n\n## Usage\nAfter setting up the Incoming Webhook Connector for your Microsoft Teams channel, it is as simple as configuring the channel and creating a new `TeamsConnector::Notification`.\n\nThe `channels` parameter can either be a single channel identifier or an array of multiple channel identifiers, that each will receive the notification. \n\n```ruby\n# TeamsConnector initializer\nTeamsConnector.configure do |config|\n  config.channel :channel_id, \"https://\u003cYOUR COMPLETE WEBHOOK URL GOES HERE\u003e\"\nend\n\n# Send a test card to your channel\nTeamsConnector::Notification.new(template: :test_card, channels: :channel_id).deliver_later\n\n# Send a card with a list of facts\ncontent = {\n  title: \"Teams Connector Readme\",\n  subtitle: \"A list of facts\",\n  facts: {\n    \"Usage\": \"Testing the facts Card\"\n  }\n}\nTeamsConnector::Notification::Message.new(:facts_card, \"This is a summary\", content).deliver_later\n```\n\n### Secure Channel Configuration\nSince the Incoming Webhook Connector does not allow any authentication at the endpoint it is crucial that you keep your channel urls secret.\nAt best nobody finds the url but it can also lead to spam or even faking of critical messages.\n\nIn Rails provides the credentials functionality for [environmental security](https://edgeguides.rubyonrails.org/security.html#environmental-security). This mechanism can be used by TeamsConnector to load channels from an encrypted file. This also allows easy separation of production and development channel URLs.\nAll channels are defined under the top-level entry `teams_connector` and will be identified by their key.\n```yaml\n# $ bin/rails credentials:edit\nteams_connector:\n  default: \"\u003cINSERT DEFAULT URL HERE\u003e\"\n  sales: \"\u003cINSERT URL FOR THE :sales CHANNEL HERE\u003e\"\n```\n\nAfter configuration of the credentials you can load the channels in your initializer.\nSince `#load_from_rails_configuration` is a wrapper around `#channel` both methods can be used together.\n\n```ruby\n# TeamsConnector initializer\nTeamsConnector.configure do |config|\n  config.load_from_rails_credentials\n  # After loading the :default channel is available and can be set as the default \n  config.default = :default\n  config.channel :another_channel, \"\u003cURL\u003e\"\nend\n```\n\n### Templates\nThis gem provides some basic templates in its default template path. You can also define your own templates in your own path.\nThe default templates will be still available so you can mix and match.\n\n#### Default templates\n\n| Template name  | Description                                                         |\n|----------------|---------------------------------------------------------------------|\n| :adaptive_card | A card with the body of an adaptive card for more complex scenarios |\n| :facts_card    | A card with title, subtitle and a list of facts                     |\n| :test_card     | A simple text message without any configurable content for testing  |\n\n#### Custom Templates\n\nCustom templates are stored in the directory specified by the configuration option `template_dir`. As an array of strings, describing the path relative to the project root. When using Rails or Bundler their root is used, otherwise it is the current working directory.\n\nTemplates are json files with the extension `.json.erb`. The file is parsed and populated by the ruby ERB module.\n\n#### Builder\n\nYou can use TeamsConnector::Builder to create Adaptive Cards directly in ruby. YOu can output the result of the builder as JSON for future use with `TeamsController::Notification::AdaptiveCard#pretty_print`.\n\n```ruby\nbuilder = TeamsConnector::Builder.container do |content|\n  content \u003c\u003c TeamsConnector::Builder.text(\"This is an introductory text for the following facts\")\n  content \u003c\u003c TeamsConnector::Builder.facts { |facts|\n    facts[\"Usage\"] = \"Testing the adaptive card builder\"\n    facts[\"Quokka fact\"] = \"They are funny little creatures\"\n  }\nend\n\nTeamsConnector::Notification::AdaptiveCard.new(content: builder).deliver_later\n```\n\n## Testing\n\nTo test TeamsConnector integration in your application you can use the `:testing` method.\nInstead of performing real HTTP requests, an array in `TeamsConnector.testing.requests` is filled with your notifications in chronological order.\n\nThe request elements have the following structure:\n```ruby\n{\n  channel: :default,\n  template: :facts_card,\n  content: '{\"rendered content\": \"in JSON format\"}',\n  time: Time.now\n}\n```\n\n### RSpec Matcher\nTeamsConnector provides the `sent_notification_to?(channel = nil, template = nil)` matcher for RSpec.\nIt is available by adding `require \"teams_connector/rspec\"` to your `spec_helper.rb`.\nThe matcher supports filtering notifications by channel and template. If one is not given, it does not filter the notifications by it.\nThere exists the alias `send_notification_to` and `have_sent_notification_to` for `sent_notification_to?`.\n\n```ruby\nit \"has sent exactly one notification to the channel\" do\n  expect { notification.deliver_later }.to sent_notification_to?(:channel)\nend\n```\n\n#### Expecting number of notifications\nBy default `sent_notification_to?` expects exactly one matching notification.\nYou can change the expected amount by chaining `exactly`, `at_least` or `at_most`.\n\nExample:\n```ruby\nit \"has sent less than 10 notifications to the channel\" do\n  expect { notification.deliver_later }.to sent_notification_to?(:channel).at_most(10)\nend\n```\n\nYou can also use `once`, `twice` and `thrice` as an alias for `exactly(1..3)`.\nFor more readable expectations `times` can be chained.\n\n#### Expecting templates\nThe template argument in the matcher does filter the notifications.\nIf you expect a template instead, you can chain with `with_template(:template)`.\n\n#### Expecting content\nTo expect specific content, you can chain with `with(data = nil, \u0026block)`.\nData supports other RSpec matchers like `hash_including`.\nThe block is called for every notification with the notification content hash and the raw notification itself.\n\nExample:\n```ruby\nexpect {\n  notification(:default, :test_card).deliver_later\n}.to sent_notification_to?(:default).with { |content, notification|\n  expect(notification[:channel]).to eq :default\n  expect(notification[:template]).to eq :test_card\n  expect(content[\"sections\"]).to include(hash_including(\"activityTitle\", \"activitySubtitle\", \"facts\", \"markdown\" =\u003e true))\n}\n```\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nYou can define the channels you use for testing in the file `bin/channels.yml` or directly in the `bin/console` script.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/qurasoft/teams_connector. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FQurasoft%2Fteams_connector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FQurasoft%2Fteams_connector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FQurasoft%2Fteams_connector/lists"}