{"id":15097688,"url":"https://github.com/sap/cloud-sdk-ios-cai","last_synced_at":"2025-10-21T10:43:32.993Z","repository":{"id":40493094,"uuid":"351312145","full_name":"SAP/cloud-sdk-ios-cai","owner":"SAP","description":"Swift package as module for interfacing with SAP Conversational AI in native iOS apps. ","archived":true,"fork":false,"pushed_at":"2024-08-12T09:33:32.000Z","size":3085,"stargazers_count":8,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-09-06T17:45:58.528Z","etag":null,"topics":["cai","chatbot","open-source","sap","swift","swiftui"],"latest_commit_sha":null,"homepage":"https://sap.github.io/cloud-sdk-ios-cai/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SAP.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-25T04:49:15.000Z","updated_at":"2025-04-04T03:38:26.000Z","dependencies_parsed_at":"2025-01-26T06:31:35.917Z","dependency_job_id":"921ea24d-df2b-40cf-8945-2c79ca680d03","html_url":"https://github.com/SAP/cloud-sdk-ios-cai","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/SAP/cloud-sdk-ios-cai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fcloud-sdk-ios-cai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fcloud-sdk-ios-cai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fcloud-sdk-ios-cai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fcloud-sdk-ios-cai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SAP","download_url":"https://codeload.github.com/SAP/cloud-sdk-ios-cai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fcloud-sdk-ios-cai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278877641,"owners_count":26061488,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cai","chatbot","open-source","sap","swift","swiftui"],"created_at":"2024-09-25T16:24:51.903Z","updated_at":"2025-10-08T02:31:46.869Z","avatar_url":"https://github.com/SAP.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv\u003e\n  \u003cp align=\"center\"\u003e\n    \u003cimg width=20% src=\"https://www.sap.com/content/dam/application/imagelibrary/pictograms/283000/283370-pictogram-purple.svg\" alt=\"Logo\" /\u003e\n    \u003c/br\u003e\n    \u003cspan\u003e\u003cb\u003eSAP Conversational AI SDK for iOS\u003c/b\u003e\u003c/span\u003e\n  \u003c/p\u003e\n    \u003chr\u003e\n  \u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://help.sap.com/docs/SAP_CONVERSATIONAL_AI/3aab817a03be4432abbfd00c42b23cb8/2e5adae21210469787e7ba351a868902.html\"\u003e\u003cb\u003e\u003ci\u003eStarting January 2023, SAP Conversational AI, SAP’s chatbot building platform has been set to maintenance mode. Existing customers can continue to use the product until the end of their contract.\u003c/i\u003e\u003c/b\u003e\u003c/a\u003e\n  \u003c/div\u003e\n  \u003chr\u003e\n  \u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://github.com/SAP/cloud-sdk-ios-cai#installation\"\u003eInstallation\n    \u003c/a\u003e\n    |\n    \u003ca href=\"https://github.com/SAP/cloud-sdk-ios-cai#examples\"\u003e Examples\n    \u003c/a\u003e\n    |\n    \u003ca href=\"https://sap.github.io/cloud-sdk-ios-cai\"\u003e API Documentation\n    \u003c/a\u003e\n    |\n    \u003ca href=\"https://github.com/SAP/cloud-sdk-ios-cai/blob/main/CHANGELOG.md\"\u003e Changelog\n    \u003c/a\u003e\n  \u003c/div\u003e\n  \u003chr\u003e\n  \u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://github.com/SAP/cloud-sdk-ios-cai/actions?query=workflow%3A%22CI%22\"\u003e\n    \u003cimg src=\"https://github.com/SAP/cloud-sdk-ios-cai/workflows/CI/badge.svg\"\n      alt=\"Build Status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://conventionalcommits.org\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg\"\n      alt=\"Conventional Commits\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://commitizen.github.io/cz-cli/\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/commitizen-friendly-brightgreen.svg\"\n      alt=\"Commitizen friendly\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://api.reuse.software/info/github.com/SAP/cloud-sdk-ios-cai\"\u003e\n    \u003cimg src=\"https://api.reuse.software/badge/github.com/SAP/cloud-sdk-ios-cai\"\n      alt=\"REUSE status\"\u003e\n    \u003c/a\u003e\n    \u003chr\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\nThe `SAPCAI` Swift Package is a module to connect to a bot on the end-to-end chatbot platform [SAP Conversational AI](https://www.sap.com/products/conversational-ai.html) (CAI). It provides a pluggable SwiftUI `AssistantView` to initiate a conversation and render the various [message types](https://help.sap.com/viewer/a4522a393d2b4643812b7caadfe90c18/latest/en-US/ad3681adae824f8a96cbcf8b889a4ffc.html) of a bot.\n\nThis Swift Package is an open-source addition to the [SAP BTP SDK for iOS](https://developers.sap.com/topics/sap-btp-sdk-for-ios.html).\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/4176826/118739439-558fdd80-b7fe-11eb-9db2-032e210c5746.gif\" alt=\"SwiftUI AssistantView\" width=\"300\" height=\"650\" align=\"center\"\u003e\n\u003c/p\u003e\n\n## Requirements\n\nLatest version\n- iOS 14 or higher\n- Xcode 12 (Swift 5.3) or higher\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003cstrong\u003ePrevious versions\u003c/strong\u003e\u003c/summary\u003e\n\nVersion 1.0.x\n- iOS 13 or higher\n- Xcode 12 (Swift 5.3) or higher\n\n\u003c/details\u003e\n\n## Prerequisites\n\n- You have existing bot(s) on the SAP Conversational AI platform\n- You have created an OAuth client for Designtime API for your bot (\u003ckbd\u003eSettings\u003c/kbd\u003e \u003e \u003ckbd\u003e Tokens\u003c/kbd\u003e)\n- Your bot(s) are connected to a mobile channel\n\n### Create a Mobile Channel\n\nIn SAP Conversational AI you create a mobile channel via the \"Connect\" tab of your bot.\n\n\u003cimg width=\"1093\" alt=\"CreateMobileChannel\" src=\"https://user-images.githubusercontent.com/4176826/119203198-549dbc80-ba47-11eb-8b65-d813324c3cc8.png\"\u003e\n\n\u003cimg alt=\"CreateMobileChannelResults\" src=\"https://user-images.githubusercontent.com/4176826/119582931-6a2e2180-bd7a-11eb-8faf-1b801a03d146.png\"\u003e\n\n## Dependencies\n\n- [SAPCommon](https://help.sap.com/doc/978e4f6c968c4cc5a30f9d324aa4b1d7/Latest/en-US/Documents/Frameworks/SAPCommon/index.html) for Logging\n- [SAPFoundation](https://help.sap.com/doc/978e4f6c968c4cc5a30f9d324aa4b1d7/Latest/en-US/Documents/Frameworks/SAPFoundation/index.html) for Network Connectivity and Authentication\n- [SDWebImage](https://github.com/SDWebImage/SDWebImage) for asynchronous image loading and gif animation in SwiftUI\n- [Down](https://github.com/johnxnguyen/Down) for Markdown / CommonMark rendering in Swift\n\n## Installation\n\nThe package is intended for consumption via Swift Package Manager. To add `SAPCAI` to your application target, navigate to the  \u003ckbd\u003eFile \u003c/kbd\u003e \u003e  \u003ckbd\u003eAdd Packages... \u003c/kbd\u003e \u003e. Use the \u003ckbd\u003eSearch or Enter Package URL\u003c/kbd\u003e field to find the package using the repository URL https://github.com/SAP/cloud-sdk-ios-cai.\n\nYou can choose one of the following package products to be added to your application/framework target.\n\n|Package Product|When to Use\n|---|---|\n|SAPCAI|You did not already embed binary frameworks from SAP BTP SDK for iOS|\n|SAPCAI-requiresToEmbedXCFrameworks|You already embedded `SAPCommon` and `SAPFoundation` binary frameworks to your target|\n\n## Getting Started\n\nThe code snippet below illustrates setting up the `CAIConversation` Combine publisher to initialize the `MessagingViewModel` for the `AssistantView`. For prototyping you can connect the iOS client directly with SAP Conversational AI *Community Edition*. You have to replace variable values in angle brackets (e.g. `\u003cchannelId\u003e`) with your bot-specific values.\n\nSee the [Enterprise Configuration](https://github.com/SAP/cloud-sdk-ios-cai/blob/main/ENTERPRISE_CONFIG.md) guide for the required configuration steps to use `SAPCAI` Swift package and connect indirectly with SAP Conversational AI *Enterprise Edition* through SAP Mobile Services.\n\n### Setting up the Data Publisher\n\n```Swift\nimport SAPCAI\nimport SAPFoundation\nimport SwiftUI\n\n/*\n  Create the `CAIChannel` object by providing the channel id, channel token, and channel slug of your mobile channel. Values can be looked up in CAI platform.\n\n  If you do not want to hardcode channel information on the client, you can retrieve a list of channels for a given Application ID with `CAIChannelService`.\n*/\nlet caiChannel = CAIChannel(id: \"\u003cchannelId\u003e\", token: \"\u003cchannelToken\u003e\", slug: \"\u003cchannelSlug\u003e\")\n\n// Create CAI service config for a SAPURLSession and URL pointing to CAI API endpoint\nlet serviceConfig = CAIServiceConfig(urlSession: SAPURLSession(), host: URL(string:\"\u003cExample: https://api.cai.tools.sap\u003e\")!)\n     \n// Provide the message delivery object for polling\nlet polling: MessageDelivering = PollMessageDelivery(channelId: \"\u003cchannelId\u003e\", serviceConfig: serviceConfig)\n   \n// Create CAIConversation object and use it as publisher\nlet dataPublisher = CAIConversation(config: serviceConfig, channel: caiChannel, messageDelivery: polling)\n\n// Create view model for `AssistantView`\nlet viewModel = MessagingViewModel(publisher: dataPublisher)\n```\n\n### User Interface\n\nUsing the SwiftUI implementation is the **preferred** approach.\n\n```Swift\n// `NavigationView` must be present in your view hierachy as `AssistantView` makes use of `NavigationLink`\nAssistantView()\n  .navigationTitle(Text(\"Chat\")) // if you are in navigation controller\n  .environmentObject(viewModel)\n  .environmentObject(ThemeManager.shared)\n  .onDisappear {\n    // you cannot rely on the fact that onDisappear will be called only\n    // once because `AssistantView` might trigger further navigations\n    // causing the `AssistantView` to disappear and re-appear.\n    // Therefore cleanup logic should be handled elsewhere.\n  })\n```\n\nbut `SAPCAI` also provides a UIKit wrapper\n\n```Swift\nlet vc = MessagingViewController(MessagingViewModel(publisher: dataPublisher))\n\nself.navigationController?.pushViewController(vc, animated: true)\n```\n\n### Cleanup\n\nOnce a conversation has ended you need to call the following functions to avoid memory leaks and unnecessary network requests. Also `MessagingViewModel` cannot be deallocated otherwise.\n\n```swift\nviewModel.cancelSubscriptions()\ndataPublisher.resetConversation()\n```\n\nSAPCAI uses `SDWebImage` and its image caching capabilities but it is the app developers responsibility to clear the cache if that is desired. Example:\n```Swift\nSDImageCache.shared.clearMemory()\nSDImageCache.shared.clearDisk(onCompletion: nil)\n```\n\n## Theming\n\n`SAPCAI` will provide two standard themes\n- a Fiori theme and\n- a Casual theme (**no longer maintained**)\n\n\u003cimg width=\"663\" alt=\"Themes\" src=\"https://user-images.githubusercontent.com/4176826/119032300-e1217f80-b960-11eb-8d65-e068958aff36.png\"\u003e\n\nEach theme will come with a color palette that supports both light and dark modes.\n\n### Fiori Theme\n\n```swift\nThemeManager.shared.setCurrentTheme( .fiori(FioriColorPalette()) )\n```\n\n### Casual Theme\n\n**No longer maintained and therefore marked as deprecated. Do not use!**\n    \n```swift\nThemeManager.shared.setCurrentTheme( .casual(CasualColorPalette()) )\n```\n\n### Create Your Own Custom Theme\n\nYou can also provide an alternative color palette or provide a custom theme.\n\n## Persistent Static Menu\n\nIn SAP Conversational AI you can add persistent static menu options to your chatbot enabling your users to quickly trigger links or skills at any point during the conversation.\n\n\u003cimg width=\"525\" alt=\"Persistent Static Menu In Bot Builder\" src=\"https://user-images.githubusercontent.com/4176826/146964912-6cceec20-ea57-4bda-90f1-b6fa339eb470.png\"\u003e\n\nUse `CAIChannelService.loadPreferences` to fetch your channel's preferences (incl. the persistent static menu) asynchronously, then set `MessagingViewModel.menu`.\n\n```Swift\nservice.loadPreferences(channel: channel) { result in\n  DispatchQueue.main.async {\n    switch result {\n      case .success(let data):\n        viewModel.menu = data?.menu\n      case .failure:\n        break\n    }\n  }\n}\n```\n\n![Persistent Static Menu Rendered by SAP CAI SDK for iOS](https://user-images.githubusercontent.com/4176826/146965541-0288dfe5-99bf-47e9-9779-d196583d6253.png)\n\n\n## Limitations\n\n### Markdown Related\n\n- **No support for [GitHub Flavored Markdown](https://github.github.com/gfm/)** (e.g. ~~strikethrough~~). Bot responses containing [Markdown](https://help.sap.com/viewer/a4522a393d2b4643812b7caadfe90c18/latest/en-US/3a3b6e09e96249b884dcf6e69eecd830.html#loio3a3b6e09e96249b884dcf6e69eecd830__section_markdown) will be rendered by the `AssistantView` according to the [Commonmark specification](https://spec.commonmark.org/0.29/) only, and unknown syntax will be treated as text. \n\n### Trigger Skill Button Related\n\n- `Trigger Skill` buttons are still enabled after execution / next interaction. This behavior differs from the SAP CAI Web Client. Once you click the button or type an utterance, the corresponding skill can't be triggered anymore at a later point in time since the context in which it was created might not be valid anymore.\n\n### Image Related\n\n- Not being able to save, copy, or share an image as part of a bot response. Currently, there is no gesture handler attached to an image view which could allow opening a contextual menu offering such features (similar to iMessage or WhatsApp).\n\n## How to Obtain Support\n\nPlease [raise an issue on GitHub](https://github.com/SAP/cloud-sdk-ios-cai/issues/new/choose). SAP customers can continue to report issues through OSS for SLA tracking.  \n\nRaise questions around CAI in the [SAP CAI Answers](https://answers.sap.com/tags/73555000100800001301) forum.\n\n## Contributing\n\nIf you want to contribute, please check the [Contribution Guidelines](./CONTRIBUTING.md).\n\n## Examples\n\nThe `CAITestApp` in this repository allows you to\n- choose a theme\n- view static mock data or\n- connect against a live system by either\n  - letting the user choose the mobile channel from the list of available mobile channels for given Application ID (a.k.a targetSystem); note: this illustrates the use of `CAIChannelService` and how to build a simple SwiftUI view on top of it\n  - loading the `AssistantView` for a specific mobile channel\n\nSee [here](https://github.com/SAP/cloud-sdk-ios-cai/tree/main/CAITestApp) on how to maintain connection settings for the test application.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fcloud-sdk-ios-cai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsap%2Fcloud-sdk-ios-cai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fcloud-sdk-ios-cai/lists"}