1.0.0 • Published 6 years ago

directly-api v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

directly-api-node-client

Currently published on npm as directly-api

Add to package.json: npm add directly-api --save

In your file:

import { directlyApi } from "directly-api";

Configuration

directlyApi.init({
    apiAccessToken: "<directly-api OAuth access token>",
    apiBaseUri: "https://api.directly.com",
    universalAccessToken: "<token from universal connector>",
    requestTimeout: <milliseconds to wait before hangup>
});

Question

// within async...

const questionParams = {
  userEmail: "<email>",
  userName: "<userName",
  text: "<question text>",
  subject: "<subject>",
  originalSystemId: "<system of origin reference id>"
};

directlyApi.askQuestion(questionParams)
  .then((directlyQuestion) => {
      ...
  })
  .catch((error) => {
      ...
  });

Message

// within async...

const messageParams = {
  questionUuid: "<questionUuid from question response>",
  responseUuid: "<from question if it already exists>",
  userEmail: "<email>",
  text: "<message text>",
  originalSystemId: "<system of origin reference id>",
  rating: <rating value>
};

directlyApi.appendMessage(demoMessage)
  .then((message: Message) => {
      ...
  })
  .catch((error) => {
      ...
  });

Process responses from Universal Connector (webhook)

Example Universal Connector config for when there is a new answer or reply

{
  "eventType": "{{event_type}}",
  "authorName": "{{answer.comment.author.name}}",
  "messageCreated": "{{answer.comment.date_created.iso8601}}",
  "messageIsAutoAnswer": {{answer.comment.is_auto_answer}},
  "message": "{{answer.comment.text}}",
  "messageAuthorIsPoster": {{answer.comment.author.is_poster}},
  "messageAuthorIsChatbot": {{answer.comment.author.is_chatbot}},
  "externalId": "{{question.external_id}}",
  "questionUuid": "{{question.uuid}}",
  "responseUuid": "{{answer.uuid}}",
  "messageUuid": "{{answer.comment.uuid}}",
  "expertName": "{{answer.expert.name}}"
}

Example Universal Connector config for when questions are rerouted to the company by an expert

{
  "eventType": "{{event_type}}",
  "externalId": "{{question.external_id}}",
  "questionUuid": "{{question.uuid}}"
}

Configure an endpoint to listen for Directly events from Universal Connector

server.post("/directly", async (req, res) => {
  const expertMessage = {};

  try {
    Object.assign(expertMessage, req.body);
    await directlyApi.processExpertResponse(expertMessage);
    res.status(200).json({ "success": true });
  } catch(error) {
    res.status(err.status).json(err).end()
  }
}

Subscribe to processed expert messages

directlyApi.subscribeToResponseMessage((expertMessage) => {
    const expertMessageJson = JSON.stringify(expertMessage);
    console.log(`Emitted response ${expertMessageJson}`);
});

TODO

currently we need to do yarn build npm link

todo - update / fix build process to work with npm run build

abababbrevacceptsacornacorn-globalsajvalign-textamdefineamqp10ansi-alignansi-escapesansi-regexansi-stylesansi-wrapansi-yellowanymatchappend-transformaprobaare-we-there-yetargparsearr-diffarr-flattenarr-unionarray-equalarray-filterarray-flattenarray-maparray-reducearray-slicearray-uniquearrifyasn1assert-plusassign-symbolsastral-regexasyncasync-eachasync-limiterasynckitatobaws-sign2aws4axiosaxios-mock-adapterbabel-code-framebabel-corebabel-generatorbabel-helpersbabel-messagesbabel-plugin-istanbulbabel-plugin-syntax-object-rest-spreadbabel-plugin-transform-es2015-modules-commonjsbabel-plugin-transform-strict-modebabel-registerbabel-runtimebabel-templatebabel-traversebabel-typesbabylonbalanced-matchbasebasic-authbcrypt-pbkdfbinary-extensionsblbluebirdbody-parserboxenbrace-expansionbracesbrowser-process-hrtimebrowser-resolvebserbuffer-builderbuffer-frombuiltin-modulesbytescache-basecallsitescamelcasecapture-exitcapture-stack-tracecaselesscenter-alignchalkchokidarchownrci-infoclass-utilscli-boxescliuicocode-point-atcollection-visitcolor-convertcolor-namecolorscombined-streamcommandercompare-versionscomponent-emittercompressibleconcat-mapconcurrentlyconfigstoreconsole-control-stringscontent-dispositioncontent-typeconvert-source-mapcookiecookie-signaturecookiejarcopy-descriptorcore-jscore-util-iscpxcreate-error-classcross-spawncrypto-random-stringcssomcssstylecycledashdashdata-urlsdate-fnsdebugdecamelizedecode-uri-componentdeep-equaldeep-extenddeep-isdefault-require-extensionsdefine-propertiesdefine-propertydelayed-streamdelegatesdepddestroydetect-filedetect-indentdetect-libcdetect-newlinediffdom-serializerdomelementtypedomexceptiondomhandlerdomutilsdot-propdotdir-regexdotenvdotenv-expandduplexerduplexer3ecc-jsbnee-firstencodeurlends-withentitieserror-exes-abstractes-to-primitiveescape-htmlescape-string-regexpescodegenesprimaestraverseesutilsetagevent-streamexec-shexecaexitexpand-bracketsexpand-rangeexpand-tildeexpectexport-filesexpressexpress-basic-authextendextend-shallowextglobextsprintfeyesfast-deep-equalfast-json-stable-stringifyfast-levenshteinfb-watchmanfilename-regexfilesetfill-rangefinalhandlerfind-indexfind-upfindup-syncflatfollow-redirectsfor-infor-ownforeachforeachasyncforever-agentform-dataformidableforwardedfragment-cachefreshfromfs-exists-syncfs-extrafs-minipassfs.realpathfseventsfunction-bindgaugeget-caller-fileget-streamget-valuegetpassglobglob-baseglob-fsglob-fs-dotfilesglob-fs-gitignoreglob-parentglob2baseglobal-dirsglobal-modulesglobal-prefixglobalsgotgraceful-fsgrowlyhandlebarshar-schemahar-validatorhashas-ansihas-flaghas-unicodehas-valuehas-valueshbshehome-or-tmphomedir-polyfillhosted-git-infohtml-encoding-snifferhtml-to-texthtmlparser2http-errorshttp-signatureiconv-liteignore-by-defaultignore-walkimport-lazyimport-localimurmurhashinflightinheritsiniinvariantinvert-kvipaddr.jsis-absoluteis-accessor-descriptoris-arrayishis-binary-pathis-bufferis-builtin-moduleis-callableis-ciis-data-descriptoris-date-objectis-descriptoris-dotdiris-dotfileis-equal-shallowis-extendableis-extglobis-finiteis-fullwidth-code-pointis-generator-fnis-globis-installed-globallyis-npmis-numberis-objis-path-insideis-plain-objectis-posix-bracketis-primitiveis-redirectis-regexis-relativeis-retry-allowedis-streamis-symbolis-typedarrayis-unc-pathis-utf8is-windowsisarrayisexeisobjectisstreamistanbul-apiistanbul-lib-coverageistanbul-lib-hookistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsistanbul-reportsjs-tokensjs-yamljsbnjsdomjsescjson-schemajson-schema-traversejson-stable-stringifyjson-stringify-safejson5jsonfilejsonifyjsprimkind-oflatest-versionlazy-cachelcidleft-padlevenlevnload-json-filelocate-pathlodashlodash.debouncelodash.sortbylongestloose-envifylowercase-keyslru-cachemake-dirmakeerrormap-cachemap-streammap-visitmath-randommedia-typermemmergemerge-descriptorsmerge-streammethodsmicromatchmimemime-dbmime-typesmimic-fnminimatchminimistminipassminizlibmixin-deepmixin-objectmkdirpmorganmsnannanomatchnatural-compareneedlenegotiatornode-int64node-notifiernode-pre-gypnodemonnoncharactersnoptnormalize-package-datanormalize-pathnpm-bundlednpm-packlistnpm-run-pathnpmlognumber-is-nannwsapioauth-signobject-assignobject-copyobject-keysobject-visitobject.getownpropertydescriptorsobject.omitobject.pickon-finishedon-headersonceoptimistoptionatoros-homediros-localeos-tmpdirosenvp-finallyp-limitp-locatep-trypackage-jsonparse-filepathparse-gitignoreparse-globparse-jsonparse-passwdparse5parseurlpascalcasepath-dirnamepath-existspath-is-absolutepath-is-insidepath-keypath-parsepath-to-regexppath-typepause-streamperformance-nowpifypinkiepinkie-promisepkg-dirpnposix-character-classesprelude-lsprepend-httppreserveprettierprettierrcpretty-formatprivateprocess-nextick-argsproxy-addrps-treepseudomappslpstree.remypunycodeqsquerystringrandomaticrange-parserraw-bodyrcread-pkgread-pkg-upreadable-streamreaddirprealpath-nativeregenerator-runtimeregex-cacheregex-notregistry-auth-tokenregistry-urlrelativeremove-trailing-separatorrepeat-elementrepeat-stringrepeatingrequestrequest-promise-corerequest-promise-nativerequire-directoryrequire-main-filenameresolveresolve-cwdresolve-dirresolve-fromresolve-urlretright-alignrimrafrsvprxsafe-buffersafe-regexsafer-buffersanesaxsemversemver-diffsendserve-staticset-blockingset-immediate-shimset-valuesetprototypeofshebang-commandshebang-regexshell-quoteshellwordssignal-exitslashsnapdragonsnapdragon-nodesnapdragon-utilsource-mapsource-map-resolvesource-map-supportsource-map-urlspawn-commandspdx-correctspdx-exceptionsspdx-expression-parsespdx-license-idssplitsplit-stringsprintf-jssshpkstack-tracestack-utilsstarts-withstately.jsstatic-extendstatusesstealthy-requirestream-combinerstring-lengthstring-widthstring_decoderstrip-ansistrip-bomstrip-eofstrip-json-commentssubargsuperagentsupertestsupports-colorsymbol-treetarterm-sizetest-excludethroatthroughthrough2timed-outtmplto-fast-propertiesto-object-pathto-regexto-regex-rangetouchtough-cookietr46tree-killtrim-righttslibtslinttsutilstunnel-agenttweetnacltype-checktype-isuglify-jsuglify-to-browserifyunc-path-regexundefsafeunderscoreunderscore.stringunion-valueunique-stringuniversalifyunpipeunset-valueunzip-responseupathupdate-notifierurixurl-parse-laxuseutil-deprecateutil.promisifyutils-mergeuuidvalidate-npm-package-licensevaryverrorw3c-hr-timewalkwalkerwatchwebidl-conversionswhatwg-encodingwhatwg-mimetypewhatwg-urlwhichwhich-modulewide-alignwidest-linewindow-sizewinstonwordwrapwrap-ansiwrappywrite-file-atomicwsxdg-basedirxml-name-validatorxtendy18nyallistyargsyargs-parser
1.1.2

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago