{"id":15066995,"url":"https://github.com/gonzalezreal/directline","last_synced_at":"2025-10-05T04:31:36.788Z","repository":{"id":56908586,"uuid":"100105974","full_name":"gonzalezreal/DirectLine","owner":"gonzalezreal","description":"Swift client library for Microsoft Bot Framework's Direct Line protocol","archived":true,"fork":false,"pushed_at":"2020-05-05T10:50:13.000Z","size":4873,"stargazers_count":12,"open_issues_count":5,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-03-14T19:17:54.850Z","etag":null,"topics":["microsoft-bot-framework","rxswift","swift4"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/gonzalezreal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-12T10:44:12.000Z","updated_at":"2023-05-31T21:38:43.000Z","dependencies_parsed_at":"2022-11-29T13:20:30.518Z","dependency_job_id":null,"html_url":"https://github.com/gonzalezreal/DirectLine","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FDirectLine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FDirectLine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FDirectLine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzalezreal%2FDirectLine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gonzalezreal","download_url":"https://codeload.github.com/gonzalezreal/DirectLine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235364841,"owners_count":18978248,"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":["microsoft-bot-framework","rxswift","swift4"],"created_at":"2024-09-25T01:14:57.689Z","updated_at":"2025-10-05T04:31:29.424Z","avatar_url":"https://github.com/gonzalezreal.png","language":"Swift","readme":"# DirectLine\n[![CocoaPods](https://img.shields.io/cocoapods/v/DirectLine.svg)](https://cocoapods.org/pods/DirectLine)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Platforms](https://img.shields.io/cocoapods/p/DirectLine.svg)](https://cocoapods.org/pods/DirectLine)\n[![Twitter: @gonzalezreal](https://img.shields.io/badge/contact-@gonzalezreal-blue.svg?style=flat)](https://twitter.com/gonzalezreal)\n\n**DirectLine** is a client library for the [Microsoft Bot Framework Direct Line](https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-direct-line-3-0-concepts) protocol.\n\nLoosely based on the official [Javascript DirectLine client](https://github.com/Microsoft/BotFramework-DirectLineJS), it enables communication between your bot and your iOS app using a simple [ReactiveX](https://github.com/ReactiveX/RxSwift) based interface.\n\n**IMPORTANT: This library is still work in progress and not at all production-ready.**\n\n## Examples\nTo create a `DirectLine` object, you must provide either the secret for your bot or a temporary token obtained via the [Generate Token](https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-direct-line-3-0-api-reference#generate-token) API:\n\n```swift\nimport DirectLine\n\nlet directLine = DirectLine(token: \"f1STR0.p3c4D0r\") \n```\n\nThe `DirectLine` object manages token renewal and web socket connection under the hood, so you don't have to worry about them.\n\nPost activities to the bot:\n\n```swift\nlet myAccount = ChannelAccount(id: \"myUserID\", name: \"Guille\")\n\ndirectLine\n  .post(activity: Activity(from: myAccount, text: \"What is my current balance?\"))\n  .subscribe(\n    onNext: { print(\"Posted activity, assigned ID (\\($0.id)\") },\n    onError: { print(\"Error posting activity \\($0)\") }\n  )\n```\n\nListen to activities sent and received from the bot:\n\n```swift\ndirectLine.activities\n  .subscribe(onNext: { activity in\n    print(\"Received activity \\(activity)\")\n  })\n```\n\nYou can leverage Rx operators on the incoming activities. For instance, to see only `message` activities:\n\n```swift\ndirectLine.activities\n  .filter { $0.type == .message }\n  .subscribe(onNext: { activity in\n    print(\"Received message \\(activity)\")\n  })\n```\n\nThe `activities` stream includes those sent to the bot, so a typical pattern is to filter them out using the `from` property:\n\n```swift\ndirectLine.activities\n  .filter { $0.type == .message  \u0026\u0026 $0.from.id == \"yourBotHandle\" }\n  .subscribe(onNext: { activity in\n    print(\"Received message from the bot \\(activity)\")\n  })\n```\n\n## Installation\n**Using CocoaPods**\n\nAdd `pod DirectLine` to your `Podfile`\n\n**Using Carthage**\n\nAdd `git \"gonzalezreal/DirectLine\"` to your `Cartfile`\n\n**Using the Swift Package Manager**\n\nAdd `Package(url: \"https://github.com/gonzalezreal/DirectLine.git\", majorVersion: 1)` to your `Package.swift` file.\n\n## Help \u0026 Feedback\n- [Open an issue](https://github.com/gonzalezreal/DirectLine/issues/new) if you need help, if you found a bug, or if you want to discuss a feature request.\n- [Open a PR](https://github.com/gonzalezreal/DirectLine/pull/new/master) if you want to make some change to `DirectLine`.\n- Contact [@gonzalezreal](https://twitter.com/gonzalezreal) on Twitter.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzalezreal%2Fdirectline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgonzalezreal%2Fdirectline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzalezreal%2Fdirectline/lists"}