GithubHelp home page GithubHelp logo

bottenderjs / messaging-apis Goto Github PK

View Code? Open in Web Editor NEW
1.9K 63.0 202.0 11.18 MB

Messaging APIs for multi-platform

Home Page: https://bottenderjs.github.io/messaging-apis/latest/

License: MIT License

JavaScript 0.17% TypeScript 99.83% Shell 0.01%
messaging messenger line api-client chatbot slack telegram bot viber wechat

messaging-apis's People

Contributors

candy02058912 avatar chentsulin avatar darkbtf avatar denistsoi avatar dependabot[bot] avatar etrex avatar evenchange4 avatar hch903 avatar homerchen19 avatar jonathanzwhite avatar kaddopur avatar kheiakiyama avatar kidkcl avatar kpman avatar littlewhiteya avatar louis70109 avatar madeinfree avatar nakanoasaservice avatar pjdon avatar playtocrazy avatar shaoruu avatar tw0517tw avatar vitaliytv avatar wtflink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

messaging-apis's Issues

Provide more helpful error messages

Progress

Before Improvement:

Messenger:

{ Error: Request failed with status code 400
    at createError (/Users/chentsulin/Projects/yoctol/tt/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/Users/chentsulin/Projects/yoctol/tt/node_modules/axios/lib/core/settle.js:18:12)
    at IncomingMessage.handleStreamEnd (/Users/chentsulin/Projects/yoctol/tt/node_modules/axios/lib/adapters/http.js:191:11)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  config:
   { adapter: [Function: httpAdapter],
     transformRequest: { '0': [Function: transformRequest] },
     transformResponse: { '0': [Function: transformResponse] },
     timeout: 0,
     xsrfCookieName: 'XSRF-TOKEN',
     xsrfHeaderName: 'X-XSRF-TOKEN',
     maxContentLength: -1,
     validateStatus: [Function: validateStatus],
     headers:
      { Accept: 'application/json, text/plain, */*',
        'Content-Type': 'application/json',
        'User-Agent': 'axios/0.16.2',
        'Content-Length': 49 },
     baseURL: 'https://graph.facebook.com/v2.10/',
     method: 'post',
     url: 'https://graph.facebook.com/v2.10/me/messages?access_token=',
     data: '{"recipient":{"id":"11"},"message":{"text":"22"}}' },
  request:
   ClientRequest {
     domain: null,
     _events:
      { socket: [Function],
        abort: [Function],
        aborted: [Function],
        error: [Function],
        prefinish: [Function: requestOnPrefinish] },
     _eventsCount: 5,
     _maxListeners: undefined,
     output: [],
     outputEncodings: [],
     outputCallbacks: [],
     outputSize: 0,
     writable: true,
     _last: true,
     upgrading: false,
     chunkedEncoding: false,
     shouldKeepAlive: false,
     useChunkedEncodingByDefault: true,
     sendDate: false,
     _removedConnection: false,
     _removedContLen: false,
     _removedTE: false,
     _contentLength: 49,
     _hasBody: true,
     _trailer: '',
     finished: true,
     _headerSent: true,
     socket:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 10,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'graph.facebook.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 265,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        write: [Function: writeAfterFIN],
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 6,
        [Symbol(bytesRead)]: 760 },
     connection:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 10,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'graph.facebook.com',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 265,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        write: [Function: writeAfterFIN],
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 6,
        [Symbol(bytesRead)]: 760 },
     _header: 'POST /v2.10/me/messages?access_token= HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json\r\nUser-Agent: axios/0.16.2\r\nContent-Length: 49\r\nHost: graph.facebook.com\r\nConnection: close\r\n\r\n',
     _onPendingData: [Function: noopPendingOutput],
     agent:
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        maxCachedSessions: 100,
        _sessionCache: [Object] },
     socketPath: undefined,
     timeout: undefined,
     method: 'POST',
     path: '/v2.10/me/messages?access_token=',
     _ended: true,
     res:
      IncomingMessage {
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        socket: [Object],
        connection: [Object],
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        headers: [Object],
        rawHeaders: [Array],
        trailers: {},
        rawTrailers: [],
        upgrade: false,
        url: '',
        method: null,
        statusCode: 400,
        statusMessage: 'Bad Request',
        client: [Object],
        _consuming: true,
        _dumped: false,
        req: [Circular],
        responseUrl: 'https://graph.facebook.com/v2.10/me/messages?access_token=',
        read: [Function] },
     aborted: undefined,
     timeoutCb: null,
     upgradeOrConnect: false,
     parser: null,
     maxHeadersCount: null,
     _redirectable:
      Writable {
        _writableState: [Object],
        writable: true,
        domain: null,
        _events: [Object],
        _eventsCount: 2,
        _maxListeners: undefined,
        _redirectCount: 0,
        _onNativeResponse: [Function],
        _currentRequest: [Circular],
        _currentUrl: 'https://graph.facebook.com/v2.10/me/messages?access_token=' },
     [Symbol(outHeadersKey)]:
      { accept: [Array],
        'content-type': [Array],
        'user-agent': [Array],
        'content-length': [Array],
        host: [Array] } },
  response:
   { status: 400,
     statusText: 'Bad Request',
     headers:
      { 'access-control-allow-origin': '*',
        'www-authenticate': 'OAuth "Facebook Platform" "invalid_request" "An active access token must be used to query information about the current user."',
        pragma: 'no-cache',
        'cache-control': 'no-store',
        'x-fb-rev': '3376047',
        'content-type': 'application/json; charset=UTF-8',
        'x-fb-trace-id': 'Ge7eqpneSnO',
        'facebook-api-version': 'v2.10',
        expires: 'Sat, 01 Jan 2000 00:00:00 GMT',
        vary: 'Accept-Encoding',
        'x-fb-debug': '9G1LNdU2ELNxNG9GzmutMdTK9yLAXGc7HAd9fgV8cvqkD6GADsAcKGlyoupQUmpwbkXRVN7dJIiKe6ZqaAPOqw==',
        date: 'Tue, 17 Oct 2017 02:31:10 GMT',
        connection: 'close' },
     config:
      { adapter: [Function: httpAdapter],
        transformRequest: [Object],
        transformResponse: [Object],
        timeout: 0,
        xsrfCookieName: 'XSRF-TOKEN',
        xsrfHeaderName: 'X-XSRF-TOKEN',
        maxContentLength: -1,
        validateStatus: [Function: validateStatus],
        headers: [Object],
        baseURL: 'https://graph.facebook.com/v2.10/',
        method: 'post',
        url: 'https://graph.facebook.com/v2.10/me/messages?access_token=',
        data: '{"recipient":{"id":"11"},"message":{"text":"22"}}' },
     request:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 49,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _header: 'POST /v2.10/me/messages?access_token= HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json\r\nUser-Agent: axios/0.16.2\r\nContent-Length: 49\r\nHost: graph.facebook.com\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/v2.10/me/messages?access_token=',
        _ended: true,
        res: [Object],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        _redirectable: [Object],
        [Symbol(outHeadersKey)]: [Object] },
     data: { error: [Object] } } }

LINE:

{ Error: Request failed with status code 401
    at createError (/Users/chentsulin/Projects/yoctol/tt/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/Users/chentsulin/Projects/yoctol/tt/node_modules/axios/lib/core/settle.js:18:12)
    at IncomingMessage.handleStreamEnd (/Users/chentsulin/Projects/yoctol/tt/node_modules/axios/lib/adapters/http.js:191:11)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  config:
   { adapter: [Function: httpAdapter],
     transformRequest: { '0': [Function: transformRequest] },
     transformResponse: { '0': [Function: transformResponse] },
     timeout: 0,
     xsrfCookieName: 'XSRF-TOKEN',
     xsrfHeaderName: 'X-XSRF-TOKEN',
     maxContentLength: -1,
     validateStatus: [Function: validateStatus],
     headers:
      { Accept: 'application/json, text/plain, */*',
        'Content-Type': 'application/json',
        Authorization: 'Bearer ',
        'User-Agent': 'axios/0.16.2',
        'Content-Length': 52 },
     baseURL: 'https://api.line.me/v2/bot/',
     method: 'post',
     url: 'https://api.line.me/v2/bot/message/push',
     data: '{"to":"11","messages":[{"type":"text","text":"22"}]}' },
  request:
   ClientRequest {
     domain: null,
     _events:
      { socket: [Function],
        abort: [Function],
        aborted: [Function],
        error: [Function],
        prefinish: [Function: requestOnPrefinish] },
     _eventsCount: 5,
     _maxListeners: undefined,
     output: [],
     outputEncodings: [],
     outputCallbacks: [],
     outputSize: 0,
     writable: true,
     _last: true,
     upgrading: false,
     chunkedEncoding: false,
     shouldKeepAlive: false,
     useChunkedEncodingByDefault: true,
     sendDate: false,
     _removedConnection: false,
     _removedContLen: false,
     _removedTE: false,
     _contentLength: 52,
     _hasBody: true,
     _trailer: '',
     finished: true,
     _headerSent: true,
     socket:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 10,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'api.line.me',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 273,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        write: [Function: writeAfterFIN],
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 6,
        [Symbol(bytesRead)]: 551 },
     connection:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 10,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'api.line.me',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 273,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        write: [Function: writeAfterFIN],
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 6,
        [Symbol(bytesRead)]: 551 },
     _header: 'POST /v2/bot/message/push HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json\r\nAuthorization: Bearer \r\nUser-Agent: axios/0.16.2\r\nContent-Length: 52\r\nHost: api.line.me\r\nConnection: close\r\n\r\n',
     _onPendingData: [Function: noopPendingOutput],
     agent:
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        maxCachedSessions: 100,
        _sessionCache: [Object] },
     socketPath: undefined,
     timeout: undefined,
     method: 'POST',
     path: '/v2/bot/message/push',
     _ended: true,
     res:
      IncomingMessage {
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        socket: [Object],
        connection: [Object],
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        headers: [Object],
        rawHeaders: [Array],
        trailers: {},
        rawTrailers: [],
        upgrade: false,
        url: '',
        method: null,
        statusCode: 401,
        statusMessage: 'Unauthorized',
        client: [Object],
        _consuming: true,
        _dumped: false,
        req: [Circular],
        responseUrl: 'https://api.line.me/v2/bot/message/push',
        read: [Function] },
     aborted: undefined,
     timeoutCb: null,
     upgradeOrConnect: false,
     parser: null,
     maxHeadersCount: null,
     _redirectable:
      Writable {
        _writableState: [Object],
        writable: true,
        domain: null,
        _events: [Object],
        _eventsCount: 2,
        _maxListeners: undefined,
        _redirectCount: 0,
        _onNativeResponse: [Function],
        _currentRequest: [Circular],
        _currentUrl: 'https://api.line.me/v2/bot/message/push' },
     [Symbol(outHeadersKey)]:
      { accept: [Array],
        'content-type': [Array],
        authorization: [Array],
        'user-agent': [Array],
        'content-length': [Array],
        host: [Array] } },
  response:
   { status: 401,
     statusText: 'Unauthorized',
     headers:
      { server: 'nginx',
        'content-type': 'application/json;charset=UTF-8',
        'x-line-request-id': 'baf9bf90-033c-489c-bc77-2424d7ad8b39',
        'x-content-type-options': 'nosniff',
        'x-xss-protection': '1; mode=block',
        'x-frame-options': 'DENY',
        'www-authenticate': 'Bearer error="invalid_token"',
        expires: 'Tue, 17 Oct 2017 02:34:29 GMT',
        'cache-control': 'max-age=0, no-cache, no-store',
        pragma: 'no-cache',
        date: 'Tue, 17 Oct 2017 02:34:29 GMT',
        connection: 'close' },
     config:
      { adapter: [Function: httpAdapter],
        transformRequest: [Object],
        transformResponse: [Object],
        timeout: 0,
        xsrfCookieName: 'XSRF-TOKEN',
        xsrfHeaderName: 'X-XSRF-TOKEN',
        maxContentLength: -1,
        validateStatus: [Function: validateStatus],
        headers: [Object],
        baseURL: 'https://api.line.me/v2/bot/',
        method: 'post',
        url: 'https://api.line.me/v2/bot/message/push',
        data: '{"to":"11","messages":[{"type":"text","text":"22"}]}' },
     request:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 52,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _header: 'POST /v2/bot/message/push HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json\r\nAuthorization: Bearer \r\nUser-Agent: axios/0.16.2\r\nContent-Length: 52\r\nHost: api.line.me\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/v2/bot/message/push',
        _ended: true,
        res: [Object],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        _redirectable: [Object],
        [Symbol(outHeadersKey)]: [Object] },
     data:
      { message: 'Authorization header required. Must follow the scheme, \'Authorization: Bearer <ACCESS TOKEN>\'' } } }

Telegram:

{ Error: Request failed with status code 404
    at createError (/Users/chentsulin/Projects/yoctol/tt/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/Users/chentsulin/Projects/yoctol/tt/node_modules/axios/lib/core/settle.js:18:12)
    at IncomingMessage.handleStreamEnd (/Users/chentsulin/Projects/yoctol/tt/node_modules/axios/lib/adapters/http.js:191:11)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1059:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
  config:
   { adapter: [Function: httpAdapter],
     transformRequest: { '0': [Function: transformRequest] },
     transformResponse: { '0': [Function: transformResponse] },
     timeout: 0,
     xsrfCookieName: 'XSRF-TOKEN',
     xsrfHeaderName: 'X-XSRF-TOKEN',
     maxContentLength: -1,
     validateStatus: [Function: validateStatus],
     headers:
      { Accept: 'application/json, text/plain, */*',
        'Content-Type': 'application/json',
        'User-Agent': 'axios/0.16.2',
        'Content-Length': 28 },
     baseURL: 'https://api.telegram.org/bot/',
     method: 'post',
     url: 'https://api.telegram.org/bot/sendMessage',
     data: '{"chat_id":"11","text":"22"}' },
  request:
   ClientRequest {
     domain: null,
     _events:
      { socket: [Function],
        abort: [Function],
        aborted: [Function],
        error: [Function],
        prefinish: [Function: requestOnPrefinish] },
     _eventsCount: 5,
     _maxListeners: undefined,
     output: [],
     outputEncodings: [],
     outputCallbacks: [],
     outputSize: 0,
     writable: true,
     _last: true,
     upgrading: false,
     chunkedEncoding: false,
     shouldKeepAlive: false,
     useChunkedEncodingByDefault: true,
     sendDate: false,
     _removedConnection: false,
     _removedContLen: false,
     _removedTE: false,
     _contentLength: 28,
     _hasBody: true,
     _trailer: '',
     finished: true,
     _headerSent: true,
     socket:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'api.telegram.org',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 226,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 6,
        [Symbol(bytesRead)]: 326 },
     connection:
      TLSSocket {
        _tlsOptions: [Object],
        _secureEstablished: true,
        _securePending: false,
        _newSessionPending: false,
        _controlReleased: true,
        _SNICallback: null,
        servername: null,
        npnProtocol: false,
        alpnProtocol: false,
        authorized: true,
        authorizationError: null,
        encrypted: true,
        _events: [Object],
        _eventsCount: 9,
        connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'api.telegram.org',
        _readableState: [Object],
        readable: false,
        domain: null,
        _maxListeners: undefined,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        _bytesDispatched: 226,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        server: undefined,
        _server: null,
        ssl: null,
        _requestCert: true,
        _rejectUnauthorized: true,
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1,
        [Symbol(asyncId)]: 6,
        [Symbol(bytesRead)]: 326 },
     _header: 'POST /bot/sendMessage HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json\r\nUser-Agent: axios/0.16.2\r\nContent-Length: 28\r\nHost: api.telegram.org\r\nConnection: close\r\n\r\n',
     _onPendingData: [Function: noopPendingOutput],
     agent:
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        maxCachedSessions: 100,
        _sessionCache: [Object] },
     socketPath: undefined,
     timeout: undefined,
     method: 'POST',
     path: '/bot/sendMessage',
     _ended: true,
     res:
      IncomingMessage {
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 3,
        _maxListeners: undefined,
        socket: [Object],
        connection: [Object],
        httpVersionMajor: 1,
        httpVersionMinor: 1,
        httpVersion: '1.1',
        complete: true,
        headers: [Object],
        rawHeaders: [Array],
        trailers: {},
        rawTrailers: [],
        upgrade: false,
        url: '',
        method: null,
        statusCode: 404,
        statusMessage: 'Not Found',
        client: [Object],
        _consuming: true,
        _dumped: false,
        req: [Circular],
        responseUrl: 'https://api.telegram.org/bot/sendMessage',
        read: [Function] },
     aborted: undefined,
     timeoutCb: null,
     upgradeOrConnect: false,
     parser: null,
     maxHeadersCount: null,
     _redirectable:
      Writable {
        _writableState: [Object],
        writable: true,
        domain: null,
        _events: [Object],
        _eventsCount: 2,
        _maxListeners: undefined,
        _redirectCount: 0,
        _onNativeResponse: [Function],
        _currentRequest: [Circular],
        _currentUrl: 'https://api.telegram.org/bot/sendMessage' },
     [Symbol(outHeadersKey)]:
      { accept: [Array],
        'content-type': [Array],
        'user-agent': [Array],
        'content-length': [Array],
        host: [Array] } },
  response:
   { status: 404,
     statusText: 'Not Found',
     headers:
      { server: 'nginx/1.10.0',
        date: 'Tue, 17 Oct 2017 02:36:02 GMT',
        'content-type': 'application/json',
        'content-length': '55',
        connection: 'close',
        'access-control-allow-origin': '*',
        'access-control-expose-headers': 'Content-Length,Content-Type,Date,Server,Connection' },
     config:
      { adapter: [Function: httpAdapter],
        transformRequest: [Object],
        transformResponse: [Object],
        timeout: 0,
        xsrfCookieName: 'XSRF-TOKEN',
        xsrfHeaderName: 'X-XSRF-TOKEN',
        maxContentLength: -1,
        validateStatus: [Function: validateStatus],
        headers: [Object],
        baseURL: 'https://api.telegram.org/bot/',
        method: 'post',
        url: 'https://api.telegram.org/bot/sendMessage',
        data: '{"chat_id":"11","text":"22"}' },
     request:
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 5,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        upgrading: false,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedConnection: false,
        _removedContLen: false,
        _removedTE: false,
        _contentLength: 28,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _header: 'POST /bot/sendMessage HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/json\r\nUser-Agent: axios/0.16.2\r\nContent-Length: 28\r\nHost: api.telegram.org\r\nConnection: close\r\n\r\n',
        _onPendingData: [Function: noopPendingOutput],
        agent: [Object],
        socketPath: undefined,
        timeout: undefined,
        method: 'POST',
        path: '/bot/sendMessage',
        _ended: true,
        res: [Object],
        aborted: undefined,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        _redirectable: [Object],
        [Symbol(outHeadersKey)]: [Object] },
     data: { ok: false, error_code: 404, description: 'Not Found' } } }

Slack

{ Error: Slack API error: not_authed
    at _http.post.then.res (/Users/chentsulin/Projects/yoctol/tt/node_modules/messaging-api-slack/lib/SlackOAuthClient.js:135:121)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
  config:
   { adapter: [Function: httpAdapter],
     transformRequest: { '0': [Function: transformRequest] },
     transformResponse: { '0': [Function: transformResponse] },
     timeout: 0,
     xsrfCookieName: 'XSRF-TOKEN',
     xsrfHeaderName: 'X-XSRF-TOKEN',
     maxContentLength: -1,
     validateStatus: [Function: validateStatus],
     headers:
      { Accept: 'application/json, text/plain, */*',
        'Content-Type': 'application/x-www-form-urlencoded',
        'User-Agent': 'axios/0.16.2',
        'Content-Length': 25 },
     baseURL: 'https://slack.com/api/',
     method: 'post',
     url: 'https://slack.com/api/chat.postMessage',
     data: 'channel=11&text=22&token=' },
  headers:
   { 'content-type': 'application/json; charset=utf-8',
     'content-length': '33',
     connection: 'close',
     'access-control-allow-origin': '*',
     date: 'Tue, 17 Oct 2017 02:38:05 GMT',
     'referrer-policy': 'no-referrer',
     server: 'Apache',
     'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
     vary: 'Accept-Encoding',
     'x-accepted-oauth-scopes': 'chat:write:user',
     'x-content-type-options': 'nosniff',
     'x-slack-backend': 'h',
     'x-slack-req-id': 'aa97e567-413c-4f69-aac2-4b83b8b86af3',
     'x-xss-protection': '0',
     'x-cache': 'Miss from cloudfront',
     via: '1.1 2b11656ee369776292ba65e603e044ed.cloudfront.net (CloudFront)',
     'x-amz-cf-id': 'wEny_2w6OxSb2O_yqGjXuiAC5ofCto-jvwbb1YGKg2cBA7K8C5TLsQ==' },
  data: { ok: false, error: 'not_authed' } }

Viber v0.4.7

Error: missing auth_token
    at ViberClient.<anonymous> (/Users/chentsulin/Projects/yoctol/ttt/node_modules/messaging-api-viber/lib/ViberClient.js:241:450)
    at Generator.next (<anonymous>)
    at step (/Users/chentsulin/Projects/yoctol/ttt/node_modules/messaging-api-viber/lib/ViberClient.js:3:565)
    at /Users/chentsulin/Projects/yoctol/ttt/node_modules/messaging-api-viber/lib/ViberClient.js:3:725
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
Error: Bad receiver ID
    at ViberClient.<anonymous> (/Users/chentsulin/Projects/yoctol/ttt/node_modules/messaging-api-viber/lib/ViberClient.js:241:450)
    at Generator.next (<anonymous>)
    at step (/Users/chentsulin/Projects/yoctol/ttt/node_modules/messaging-api-viber/lib/ViberClient.js:3:565)
    at /Users/chentsulin/Projects/yoctol/ttt/node_modules/messaging-api-viber/lib/ViberClient.js:3:725
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

auto generate docs?

I've seen documentationjs supports flow type.
https://github.com/documentationjs/documentation/blob/master/docs/GETTING_STARTED.md#flow-type-annotations
but it seems not supporting the class method syntax we are using.
for example they support this:

  /**
   * Get User Profile
   *
   * https://www.quora.com/How-connect-Facebook-user-id-to-sender-id-in-the-Facebook-messenger-platform
   * first_name, last_name, profile_pic, locale, timezone, gender
   */
  getUserProfile(userId: string): Promise<User> {
    return this._http.get(`/${userId}?access_token=${this._accessToken}`);
  }

but didn't support this:

  /**
   * Get User Profile
   *
   * https://www.quora.com/How-connect-Facebook-user-id-to-sender-id-in-the-Facebook-messenger-platform
   * first_name, last_name, profile_pic, locale, timezone, gender
   */
  getUserProfile = (userId: string): Promise<User> =>
    this._http.get(`/${userId}?access_token=${this._accessToken}`);

support create subscription

POST /${APP_ID}/subscriptions

{
  object: 'page',
  callback_url': '<YOUR_CALLBACK_URL>',
  fields: 'conversations',
  verify_token: '<YOUR_VERIFY_TOKEN>',
}

Telegram implement getFileLink()

const { result: { file_path } } = await context.client.getFile(
    context.event._rawEvent.message.photo.pop().file_id
);
const fileLink = `https://api.telegram.org/file/bot${context.client._token}/${file_path}`;

v0.2 check list

  • support Greeting Text locale #19
  • And more methods to reply and multicast #27
  • changelog
  • docs
  • release

Support pass quick_replies as options to any message

sendText(USER_ID, 'xxxx', {
    quick_replies: [
        {
            content_type: 'text',
            title: '<BUTTON_TEXT>',
            image_url: 'http://example.com/img/red.png',
            payload: '<STRING_SENT_TO_WEBHOOK>'
         },
    ],
});

instead of

sendQuickReplies(USER_ID, 'xxxx', [
    {
        content_type: 'text',
        title: '<BUTTON_TEXT>',
        image_url: 'http://example.com/img/red.png',
        payload: '<STRING_SENT_TO_WEBHOOK>'
     },
]);

To support send quick_replies with any message

uploadAttachment buffer data

I saw that @chentsulin recently merged in a PR that added buffer support for uploadAttachment. Thanks for doing that ๐Ÿ˜„

I'm trying to use a buffer to upload an image attachment straight to Messenger without saving the file on my server.

The following function calls work for me:

client.uploadAttachment('image', 'http://www.example.com/image.jpg');
client.uploadAttachment('image', fs.createReadStream('image.jpg'));

However, if I pass a buffer to uploadAttachment I get the following error:

Messenger API - 100 OAuthException (#100) Incorrect number of files uploaded. Must upload exactly one file.

For example, if I submit multi-part form data to my server with a file and pass the buffer to uploadAttachment I get the above error.

client.uploadAttachment('image', req.file.buffer);

I found this StackOverflow post that suggests that you need to set a filename. I tested adding a filename on the following line and it seemed to resolve the issue: https://github.com/Yoctol/messaging-apis/blob/87bb438de1524514a319622f4c614f64bd123af1/packages/messaging-api-messenger/src/MessengerClient.js#L1228

support message builder in LINE

reply_token can only be used once, so it's nice if we can build multiple messages more easily.

client.reply(ReplyToken, [
  LINE.createText('Hello');
  LINE.createText('World');
]);

get pageId from token

We can get pageId directly using Graph API:

https://graph.facebook.com/v2.11/me?access_token=<token>

Will get response:

{
  "name": "Bot Demo",
  "id": "1895382890692545"
}

Concrete API implementations differ from one another

Each implementations of a messaging API (e.g messaging-api-messenger and messaging-api-line) differ in their API which prevents polymorphic use-cases where I pass an instance of a messaging API to a component of my application without explicitely knowing what real API this is.

For instance, messaging-api-messenger implements the sendText method where messaging-api-line implements the pushText method for sending messages, where they could both implement the same method name.

Is there any reason behind this choice ?

Cannot launch the script

I get this error when launching my js script after installation

(function (exports, require, module, __filename, __dirname) { import {
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:393:7)
at startup (bootstrap_node.js:150:9)

Support upload attachment from buffer or stream

Now we only support upload attachment using url:

client.uploadAttachment(type, 'http://xxx.com/xxx.jpg');

We should support using buffer or stream:

client.uploadAttachment(type, buffer);
client.uploadAttachment(type, fs.creatReadStream('xxx.jpg'));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.