Skip to content

Commit

Permalink
Merge pull request pnp#108 from RodCoder/master
Browse files Browse the repository at this point in the history
QnA Chatbot using cognitive services
  • Loading branch information
VesaJuvonen committed Feb 26, 2018
2 parents 139f303 + 74f9d1b commit af30f2c
Show file tree
Hide file tree
Showing 25 changed files with 17,081 additions and 0 deletions.
25 changes: 25 additions & 0 deletions samples/react-application-qna-chat/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]

# change these settings to your own preference
indent_style = space
indent_size = 2

# we recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[{package,bower}.json]
indent_style = space
indent_size = 2
32 changes: 32 additions & 0 deletions samples/react-application-qna-chat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules

# Build generated files
dist
lib
solution
temp
*.sppkg

# Coverage directory used by tools like istanbul
coverage

# OSX
.DS_Store

# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj

# Resx Generated Code
*.resx.ts

# Styles Generated Code
*.scss.ts
8 changes: 8 additions & 0 deletions samples/react-application-qna-chat/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"@microsoft/generator-sharepoint": {
"version": "1.4.1",
"libraryName": "react-application-qna-chat",
"libraryId": "96c6cbe3-d7c4-4156-96f1-25ac572cd657",
"environment": "spo"
}
}
69 changes: 69 additions & 0 deletions samples/react-application-qna-chat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# QnA Chatbot

## Summary
SPFx application extension that uses Azure QnA cognitive services to efficiently answer FAQs.

![QnA chatbot](./assets/qnachatbot.png)

## Used SharePoint Framework Version

![SPFx v1.4.1](https://img.shields.io/badge/SPFx-1.4.1-green.svg)

## Applies to

* [SharePoint Framework Extensions](https://dev.office.com/sharepoint/docs/spfx/extensions/overview-extensions)

## Solution

Solution|Author(s)
--------|---------
react-application-qna-chat|Rodrigo Silva, @RodResendeSilva)

## Version history

Version|Date|Comments
-------|----|--------
1.0.0|February 23, 2017|Initial release

## Disclaimer

**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

---

## Prerequisites

* Office 365 Developer tenant with a modern site collection
* Cognitive Services QnA API Key and Knowledge Base ID
(more info [https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/home](https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/home))
(quick start video [https://qnamaker.ai/Documentation/quickstart](https://qnamaker.ai/Documentation/quickstart)))

## Minimal Path to Awesome

* clone this repo
* edit "cognitiveservices.ts" file to set your Cognitive Services API Key and Knowledge Base ID:

```ts
private qnamakerSubscriptionKey: string = "[INSERT KEY HERE]";
private knowledgebaseId: string = "[INSERT KB ID HERE]";
```

* in the command line run
* `npm i`
* `gulp serve-info --nobrowser`

```
?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"1b3557f3-315d-4187-8d58-60e88e93d654":{"location":"ClientSideExtension.ApplicationCustomizer"}}
```

## Features

Sample SharePoint Framework application extension.

This sample illustrates the following concepts on top of the SharePoint Framework:

* using QnA Cognitive Services API
* how to improve your employees FAQ experience
* using async / await for the async calls
* how to take advantage of existing react npm packages

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions samples/react-application-qna-chat/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://dev.office.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"qn-a-chat-application-customizer": {
"components": [
{
"entrypoint": "./lib/extensions/qnAChat/QnAChatApplicationCustomizer.js",
"manifest": "./src/extensions/qnAChat/QnAChatApplicationCustomizer.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"QnAChatApplicationCustomizerStrings": "lib/extensions/qnAChat/loc/{locale}.js"
}
}
4 changes: 4 additions & 0 deletions samples/react-application-qna-chat/config/copy-assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://dev.office.com/json-schemas/spfx-build/copy-assets.schema.json",
"deployCdnPath": "temp/deploy"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://dev.office.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./temp/deploy/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "react-application-qna-chat",
"accessKey": "<!-- ACCESS KEY -->"
}
25 changes: 25 additions & 0 deletions samples/react-application-qna-chat/config/package-solution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://dev.office.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "react-application-qna-chat-client-side-solution",
"id": "96c6cbe3-d7c4-4156-96f1-25ac572cd657",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"features": [
{
"title": "Application Extension - Deployment of custom action.",
"description": "Deploys a custom action with ClientSideComponentId association",
"id": "644a4f9e-c80e-482d-b2da-b7d72418e508",
"version": "1.0.0.0",
"assets": {
"elementManifests": [
"elements.xml"
]
}
}
]
},
"paths": {
"zippedPackage": "solution/react-application-qna-chat.sppkg"
}
}
29 changes: 29 additions & 0 deletions samples/react-application-qna-chat/config/serve.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://dev.office.com/json-schemas/core-build/serve.schema.json",
"port": 4321,
"https": true,
"serveConfigurations": {
"default": {
"pageUrl": "https://contoso.sharepoint.com/sites/mySite/SitePages/myPage.aspx",
"customActions": {
"1b3557f3-315d-4187-8d58-60e88e93d654": {
"location": "ClientSideExtension.ApplicationCustomizer",
"properties": {
"testMessage": "Test message"
}
}
}
},
"qnAChat": {
"pageUrl": "https://contoso.sharepoint.com/sites/mySite/SitePages/myPage.aspx",
"customActions": {
"1b3557f3-315d-4187-8d58-60e88e93d654": {
"location": "ClientSideExtension.ApplicationCustomizer",
"properties": {
"testMessage": "Test message"
}
}
}
}
}
}
45 changes: 45 additions & 0 deletions samples/react-application-qna-chat/config/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "https://dev.office.com/json-schemas/core-build/tslint.schema.json",
// Display errors as warnings
"displayAsWarning": true,
// The TSLint task may have been configured with several custom lint rules
// before this config file is read (for example lint rules from the tslint-microsoft-contrib
// project). If true, this flag will deactivate any of these rules.
"removeExistingRules": true,
// When true, the TSLint task is configured with some default TSLint "rules.":
"useDefaultConfigAsBase": false,
// Since removeExistingRules=true and useDefaultConfigAsBase=false, there will be no lint rules
// which are active, other than the list of rules below.
"lintConfig": {
// Opt-in to Lint rules which help to eliminate bugs in JavaScript
"rules": {
"class-name": false,
"export-name": false,
"forin": false,
"label-position": false,
"member-access": true,
"no-arg": false,
"no-console": false,
"no-construct": false,
"no-duplicate-case": true,
"no-duplicate-variable": true,
"no-eval": false,
"no-function-expression": true,
"no-internal-module": true,
"no-shadowed-variable": true,
"no-switch-case-fall-through": true,
"no-unnecessary-semicolons": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-with-statement": true,
"semicolon": true,
"trailing-comma": false,
"typedef": false,
"typedef-whitespace": false,
"use-named-parameter": true,
"valid-typeof": true,
"variable-name": false,
"whitespace": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://dev.office.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
}
7 changes: 7 additions & 0 deletions samples/react-application-qna-chat/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);

build.initialize(gulp);
Loading

0 comments on commit af30f2c

Please sign in to comment.