Skip to content

How to create a Telegram, Facebook Messenger, and Google Assistant bot with Swift using Vapor on Linux and macOS.

License

Notifications You must be signed in to change notification settings

FabrizioBrancati/SwiftyBot

Repository files navigation

SwiftyBot Banner

Build Status Codebeat Badge Version Language Platform License


What does it doCompatibilityLanguage supportRequirementsCommunicationContributingInstalling and UsageDocumentationChangelogDemoTodoAuthorLicense


What does it do

SwiftyBot is an example on how to create a Telegram & Facebook Messenger bot with Swift using Vapor.
See Compatibility section to check service and version it supports, you can also see its blog post with the link in that table.

Compatibility

Bot Type Version Blog Post Link
Telegram 1.0...1.2 How to create a Telegram bot with Swift using Vapor on Ubuntu / macOS
Facebook Messenger 2.0 How to create a Facebook Messenger bot with Swift

Language support

  • English (en)

Requirements

  • Ubuntu 14.04 or later with Swift 3.0.2 / macOS with Xcode 8.2
  • Telegram account and a Telegram App for any platform (Telegram bot only)
  • Facebook account and a Facebook Messenger App for any platform (Facebook Messenger bot only)

Communication

  • If you need help, use Stack Overflow.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, see Contributing section.

Contributing

See CONTRIBUTING.md file.

Installing and Usage

Telegram

  • Install Swift on your computer / server
  • Install Vapor Toolbox (Optional)
  • Set a secret key in secrets/app.json
  • Enable TLS (You can use Let's Encrypt)
  • Use Apache or nginx as reverse proxy
  • Create a Telegram bot with BotFather
  • Use Supervisor to ensure your bot is always running

If you need more help through this steps, you can read How to create a Telegram bot with Swift using Vapor on Ubuntu / macOS blog post.

Facebook Messenger

  • Install Swift on your computer / server
  • Install Vapor Toolbox (Optional)
  • Set a secret key in secrets/app.json
  • Enable TLS (You can use Let's Encrypt)
  • Use Apache or nginx as reverse proxy
  • Create a Facebook App and Page
  • Get a Page access token and add it to secrets/app.json
  • Use Supervisor to ensure your bot is always running

If you need more help through this steps, you can read How to create a Facebook Messenger bot with Swift blog post.

Documentation

Every line of main.swift file is commented.
If you need Vapor documentation you can find it here.
If you need Telegram bot documentation you can find it here.
If you need Facebook Messenger bot documentation you can find it here.

Changelog

To see what has changed in recent version of SwiftyBot, see the CHANGELOG.md file.

Demo

Telegram

You can open Telegram and search for SwiftyBot and start talking with him!

Facebook Messenger

You can open Facebook and search for SwiftyBot and start talking with him!

Todo

  • Add more functions and commands
  • Add support for combined emoji on Linux
  • Add support for edited messages
  • Add support for images
  • Include BFKit-Swift dependency

Author

Fabrizio Brancati

Website: https://www.fabriziobrancati.com
Email: [email protected]

Icon

Roberto Chiaveri

Website: http:https://robertochiaveri.it

License

SwiftyBot is available under the MIT license. See the LICENSE file for more info.