Classes

GraphApi

Experimental chatbot API

Functions

postBackApi(processor, [acl])PostBackAPI

Create a postback API

validateBotApi(botFactory, [postBackTest], [textTest], [acl])ValidateBotAPI

Test the bot configuration

conversationsApi(stateStorage, chatLogStorage, notifications, [acl])ConversationsAPI

Create a conversations API for retrieving conversations and it's history

apiAuthorizer(args, ctx, acl)boolean

If API call is authorized - use for own implementations of API endpoints

Typedefs

GraphQlResponse : Object
PostBackAPI : Object
ValidateBotAPI : Object
conversation : Object
StateStorage : Object
Notifications : Object
ChatLogStorage : Object
 

GraphApi

Experimental chatbot API

Kind: global class

 

new GraphApi(apis, options)

Params

  • apis Array.<Object> - list of connected APIs
  • options Object - API options
    • .token string - wingbot token
    • [.appToken] string - public token
    • [.groups] Array.<string> - list of allowed bot groups
 

graphApi.request(body, headers, [wingbotToken]) ⇒ Promise.<GraphQlResponse>

Kind: instance method of GraphApi
Params

  • body Object
    • .query Object
    • [.variables] Object
    • [.operationName] string
  • headers Object
    • [.Authorization] string
    • [.authorization] string
  • [wingbotToken] string
 

postBackApi(processor, [acl]) ⇒ PostBackAPI

Create a postback API

Kind: global function
Params

  • processor Object - running messaging channel, like Facebook
  • [acl] Array.<string> | function - limit api to array of groups or use auth function

Example

const { GraphApi, postBackApi } = require('wingbot');

const api = new GraphApi([
    postBackApi(channel)
], {
    appToken: 'API-will-be-accessible-with-this-token-in-Authorization-header'
})
 

validateBotApi(botFactory, [postBackTest], [textTest], [acl]) ⇒ ValidateBotAPI

Test the bot configuration

Kind: global function
Params

  • botFactory function - function, which returns a bot
  • [postBackTest] string | null - postback action to test
  • [textTest] string | null - random text to test
  • [acl] Array.<string> | function - limit api to array of groups or use auth function

Example

const { GraphApi, validateBotApi } = require('wingbot');

const api = new GraphApi([
    validateBotApi(botFactory, 'start', 'hello')
], {
    token: 'wingbot-token'
})
 

conversationsApi(stateStorage, chatLogStorage, notifications, [acl]) ⇒ ConversationsAPI

Create a conversations API for retrieving conversations and it's history

Kind: global function
Params

 

apiAuthorizer(args, ctx, acl) ⇒ boolean

If API call is authorized - use for own implementations of API endpoints

Kind: global function
Params

  • args Object - gql request
  • ctx Object - request context
  • acl Array.<string> | null | function - custom acl settings

Example

const { apiAuthorizer } = require('wingbot');

function createApi (acl = null) {
    return {
         gqlEndpoint (args, ctx) {
             if (!apiAuthorizer(args, ctx, acl)) {
                 return null;
             }
         }
    }
}
 

GraphQlResponse : Object

Kind: global typedef
Params

  • [data] *
  • [errors] Array.<Object>
 

PostBackAPI : Object

Kind: global typedef
Properties

Name Type
postBack function
 

ValidateBotAPI : Object

Kind: global typedef
Properties

Name Type
validateBot function
 

conversation : Object

Kind: global typedef

 

StateStorage : Object

Kind: global typedef
Properties

Name Type
getStates function
getState function
 

Notifications : Object

Kind: global typedef
Properties

Name Type
getSubscribtions function
 

ChatLogStorage : Object

Kind: global typedef
Properties

Name Type
getInteractions function

results matching ""

    No results matching ""