1.1.4 • Published 7 years ago

broid-skype v1.1.4

Weekly downloads
2
License
AGPL-3.0+
Repository
github
Last release
7 years ago

npm node deps tests bithound bithoundscore nsp-checked

Broid Skype Integration

Broid Integrations is an open source project providing a suite of Activity Streams 2 libraries for unified communications among a vast number of communication platforms.

Connect your App to Multiple Messaging Channels with One OpenSource Language.

gitter

Message types supported

SimpleImageVideoButtonsLocationPhone number

Location, Phone number are platform limitations.

Getting started

Connect to Skype

import broidSkype from 'broid-skype'

const skype = new broidSkype({
  token: 'xxxxx',
  tokenSecret: 'xxxxxx',
})

skype.connect()
  .subscribe({
    next: data => console.log(data),
    error: err => console.error(`Something went wrong: ${err.message}`),
    complete: () => console.log('complete'),
  })

Options availables

nameTypedefaultDescription
tokenstring
token_secretstring
service_idstringrandomArbitrary identifier of the running instance
log_levelstringdebugCan be : fatal, error, warn, info, debug, trace
httpobject{ "port": 8080, "http": "0.0.0.0" }HTTP options (host, port)

Receive a message

skype.listen()
  .subscribe({
    next: data => console.log(`Received message: ${data}`),
    error: err => console.error(`Something went wrong: ${err.message}`),
    complete: () => console.log('complete'),
  })

Buttons supported

mediaTypeAction typesContent of value property
text/htmlopen-urlURL to be opened in the built-in browser.
audio/telephone-eventcallDestination for a call in following format: "tel:123123123123".
imBackText of message which client will sent back as ordinary chat message.

Post a message

To send a message, the format should use the broid-schemas.

const message_formated = '...'

skype.send(message_formated)
  .then(() => console.log("ok"))
  .catch(err => console.error(err))

Examples of messages

Message received

  • A simple direct message received from Sally
{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Create",
  "published": 1482903365195,
  "generator": {
    "id": "f6e92eb6-f69e-4eae-8158-06613461cf3a",
    "type": "Service",
    "name": "skype"
  },
  "actor": {
    "type": "Person",
    "name": "Sally",
    "id": "2932680234"
  },
  "object": {
    "type": "Note",
    "content": "hello world",
    "id": "814382944357937155",
    "context": {
      "type": "Object",
      "content": "xxxxxxx#29:xxxxxxx#skype#28:xxxxxxxx"
    }
  },
  "target": {
    "type": "Person",
    "name": "MyBot",
    "id": "1132680234"
  }
}
  • A image received from Sally
{
 "@context": "https://www.w3.org/ns/activitystreams",
 "published": 1483147401733,
 "type": "Create",
 "generator": {
   "id": "bf4ef3de-486b-40ea-80e1-e8d5af86d81c",
   "type": "Service",
   "name": "skype"
 },
 "actor": {
   "id": "29:xxxxxxxxx",
   "type": "Person",
   "name": "Sally"
 },
 "target": {
   "type": "Person",
   "name": "MyBot",
   "id": "28:xxxxxxxxxxxx"
 },
 "object": {
   "type": "Image",
   "id": "1483147401729",
   "context": {
     "type": "Object",
     "name": "address_id",
     "content": "xxxxxxx#29:xxxxxxxxxxxx#skype#28:xxxxxxxxxxxx"
   },
   "url": "https://apis.skype.com/v2/attachments/0-cus-d1-432cb4158e59c36bc0814217ecf46318/views/original",
   "mediaType": "image/jpeg",
   "name": "image_name.jpg"
 }
}

Send a message

  • Send a simple message
{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Create",
  "generator": {
    "id": "f6e92eb6-f69e-4eae-8158-06613461cf3a",
    "type": "Service",
    "name": "skype"
  },
  "object": {
    "type": "Note",
    "content": "hello world",
    "context": {
      "type": "Object",
      "name": "address_id",
      "content": "xxxxxxx#29:xxxxxxxxxxxx#skype#28:xxxxxxxxxxxx"
    }
  },
  "to": {
    "type": "Person",
    "id": "2932680234"
  }
}
  • Send a Image, Video
{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Create",
  "generator": {
    "id": "f6e92eb6-f69e-4eae-8158-06613461cf3a",
    "type": "Service",
    "name": "skype"
  },
  "object": {
    "content": "hello world",
    "type": "Image",
    "url": "https://unsplash.it/200/300",
    "context": {
      "type": "Object",
      "name": "address_id",
      "content": "xxxxxxx#29:xxxxxxxxxxxx#skype#28:xxxxxxxxxxxx"
    }    
  },
  "to": {
    "type": "Person",
    "id": "2932680234"
  }
}
  • Send quick reply message
{
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Create",
  "generator": {
    "id": "f6e92eb6-f69e-4eae-8158-06613461cf3a",
    "type": "Service",
    "name": "skype"
  },
  "object": {
    "type": "Note",
    "content": "hello world",
    "attachment": [{
        "type": "Button",
        "content": "Broid's website",
        "name": "broid",
        "mediaType": "text/html",
        "url": "https://www.broid.ai"
    }, {
        "type": "Button",
        "content": "Falken's Maze",
        "name": "maze",
        "url": "value_maze"
    }],
    "context": {
      "type": "Object",
      "name": "address_id",
      "content": "xxxxxxx#29:xxxxxxxxxxxx#skype#28:xxxxxxxxxxxx"
    }    
  },
  "to": {
    "type": "Person",
    "id": "2932680234"
  }
}

Contributing to Broid

Broid is an open source project. Broid wouldn't be where it is now without contributions by the community. Please consider forking Broid to improve, enhance or fix issues. If you feel like the community will benefit from your fork, please open a pull request.

And because we want to do the better for you. Help us improving Broid by sharing your feedback on our Integrations GitHub Repo and let's build Broid together!

Code of Conduct

Make sure that you're read and understand the Code of Conduct.

Copyright & License

Copyright (c) 2016-2017 Broid.ai

This project is licensed under the AGPL 3, which can be found here.