Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge all of v2 branch to main #43

Merged
merged 53 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
9d4f34e
Attachment view and download UI (#21)
akshaymayekar Feb 2, 2024
d363ffa
added border for image
shivamarora1 Feb 5, 2024
9c77ee3
Merge pull request #23 from tarkalabs/fix/image-border-radius
akshaymayekar Feb 5, 2024
bf6f197
Updated version and performed build
shamilsdq Feb 5, 2024
bc2ebd1
Merge pull request #24 from tarkalabs/build-v2.0.2
akshaymayekar Feb 5, 2024
a972113
fix/24080: removed fixed width and height of image-container
shivamarora1 Feb 9, 2024
3344fa1
Merge pull request #28 from tarkalabs/fix/24080
shivamarora1 Feb 12, 2024
759e305
Merge pull request #29 from tarkalabs/main
shivamarora1 Feb 12, 2024
c075e03
Added repo details (#30)
shamilsdq Feb 12, 2024
b102a3a
Bump version to 2.1.0
actions-user Feb 12, 2024
f152f48
add changes for highchart
shivamarora1 Feb 12, 2024
21ff17e
feat(#24108): highchart changes
shivamarora1 Feb 12, 2024
ae890f2
changes in initjs
shivamarora1 Feb 13, 2024
52b0160
removed highchart dep
shivamarora1 Feb 13, 2024
7cbe549
merged with v2
shivamarora1 Feb 13, 2024
b8e6a68
space in init.js
shivamarora1 Feb 13, 2024
b1b493c
feat/24108: increased width of highchart container, title fontWeight:…
shivamarora1 Feb 13, 2024
84e6f2b
PR changes
shivamarora1 Feb 14, 2024
2a1a7d5
Merge pull request #31 from tarkalabs/feat/24108-integration-high-charts
shivamarora1 Feb 14, 2024
023c9c3
Bump version to 2.2.0
actions-user Feb 14, 2024
b912d8e
Fix issue with file download not working in iframe
akshaymayekar Feb 20, 2024
1775551
Merge pull request #32 from tarkalabs/fix-file-download-in-iframe
akshaymayekar Feb 21, 2024
8056c20
Updated tarka chat version
akshaymayekar Feb 21, 2024
3014819
Merge pull request #34 from tarkalabs/update-version-2.2.1
akshaymayekar Feb 21, 2024
924df19
Bump version to 2.2.1
actions-user Feb 21, 2024
57104e9
Add file upload support (#33)
shamilsdq Feb 22, 2024
4bb1ad4
Bump version to 2.3.0
actions-user Feb 22, 2024
92c1371
added table for textual response
shivamarora1 Feb 26, 2024
1202a18
some visualization issue fixed
shivamarora1 Feb 27, 2024
5bc1b5f
some changes
shivamarora1 Feb 28, 2024
d479c2e
added array check
shivamarora1 Feb 28, 2024
fba1f0b
fixed dict condition
shivamarora1 Feb 28, 2024
0836594
added readme file
shivamarora1 Feb 28, 2024
9fef6b8
Merge pull request #35 from tarkalabs/feat/#2413
shivamarora1 Feb 28, 2024
1fac14e
no change
shivamarora1 Feb 28, 2024
798cab4
Merge pull request #36 from tarkalabs/bump/24313
shivamarora1 Feb 28, 2024
d7fdde1
Bump version to 2.3.1
actions-user Feb 28, 2024
97e3a26
#feat: Made highcharts optional + refactoring
su-docker Mar 14, 2024
3162f4c
Merge pull request #37 from tarkalabs/refactor-and-fixes
su-docker Mar 15, 2024
1ab9fa4
#refactor : Remove release information from read
su-docker Mar 15, 2024
4b7224a
#doc : Add missing documentation for enableUpload flag
su-docker Mar 15, 2024
58d3b35
Merge pull request #39 from tarkalabs/missing-doc-for-enableupload-flag
su-docker Mar 18, 2024
dc59a0a
Merge branch 'v2' into remove-release-md
su-docker Mar 18, 2024
bf844fd
Merge pull request #38 from tarkalabs/remove-release-md
su-docker Mar 18, 2024
65f107e
#feat Enable markdown
su-docker Mar 25, 2024
82c71f3
Merge pull request #40 from tarkalabs/enable-markdown
su-docker Mar 25, 2024
2bc2409
Bumping the version to 2.4.0
su-docker Mar 25, 2024
9ccba87
Revert "Bumping the version to 2.4.0"
su-docker Mar 25, 2024
b030446
chore: Update the markdown example for clarity
su-docker Mar 25, 2024
4d202c9
Merge pull request #41 from tarkalabs/release-v2.4
su-docker Mar 25, 2024
5b753c4
bug: Update the node version to 18 as needed by marked module
su-docker Mar 25, 2024
dbf32a4
Merge pull request #42 from tarkalabs/release-v2.4
su-docker Mar 25, 2024
dba8011
Bump version to 2.4.0
actions-user Mar 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/bump-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: "16"
node-version: "18"

- name: Bump version
run: |
Expand Down Expand Up @@ -52,4 +52,4 @@ jobs:
git config user.email "actions@github.com"
git add package.json dist/
git commit -m "Bump version to ${{ steps.get_version.outputs.version }}"
git push origin HEAD:v2
git push origin HEAD:v2
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.19.0
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
92 changes: 85 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

Tarka Chat UI is a plug and play javascript library to integrate a chat assistant to your website in one line


## Usage

1. Incude the following script (hosted in CDN) in your html

```
<script src="https://d1fmfone96g0x2.cloudfront.net/tarka-chat-2.0.2.umd.js"></script>
```
```
<script src="https://d1fmfone96g0x2.cloudfront.net/tarka-chat-2.2.1.umd.js"></script>
```

Include highcharts library to generate charts by highcharts

```
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
```

2. Initialise the global `TarkaChat` component with options in any script tag

Expand All @@ -22,6 +27,7 @@ TarkaChat.init({
themeColor: "#F0DAFB",
selectorId: "chatbot",
expand: true,
enableUpload: true,
preChatRenderer: function (onClose) {
// Return a DOM Node that can be attached to the chatbot UI
// Use the onClose callback to close the pre-chat screen
Expand All @@ -43,20 +49,92 @@ where,
- [Optional] **title** is the title of the chatbot window
- [Optional] **botName** will be displayed below each bot message
- [Optional] **expand** opens the chat window in expanded mode on init when set to true, otherwise opens in collapse mode. Defaults to false.
- [Optional] **enableUpload** will show the option to upload a file when set to true. False by default
- **greeting** will be the first message displayed on the chatbot when opened for the first time
- **themeColor** will set the color scheme of the chat window
- **selectorId** the DOM element selector (id) inside which the bot will be rendered
- **submitHandler** this function will be called whenever a user types a message in the bot and submits

Returned response from submitHandler should be one the below types:

1. _String_
2. One of the below objects:

- _Text type:_

```
{
"type": "text",
"message": "MESSAGE"
}
```

- _File type:_

```
{
"type": "file",
"link": "LINK_TO_FILE",
"name": "FILE_NAME",
}
```

- _Image type:_

```
{
"type": "image",
"link": "LINK_TO_IMAGE",
"name": "IMAGE_NAME",
}
```

- _HighCharts config type:_

```
{
"type": "highchart-config",
"high_chart_config": { highcharts_config_obj }
}
```

- _Table type:_

```
{
"type": "table",
"table_data": { "header":[],"rows":[{}] }
}
```

3. _Array containing one/multiple of above mentioned types:_
E.g.

```
[
{
"type": "text",
"message": "MESSAGE"
},
{
"type": "file",
"link": "LINK_TO_FILE",
"name": "FILE_NAME",
}
]
```

## Demo

Demo is deployed from the application code in `demo/` folder.
Link: https://tarkalabs.github.io/tarka-chat/demo/

## Dev notes

If you wanted to run this code in your local for development purposes, Run the following command from project root folder `yarn dev` and open `dev/index.html` in your browser to see the chat window. Your local changes will be hot reloaded

## Old versions

* v1.1 : https://d1fmfone96g0x2.cloudfront.net/tarka-chat-1.1.umd.js
* v1.0 : https://d1fmfone96g0x2.cloudfront.net/tarka-chat-1.1.umd.js
- v1.1 : https://d1fmfone96g0x2.cloudfront.net/tarka-chat-1.1.umd.js
- v1.0 : https://d1fmfone96g0x2.cloudfront.net/tarka-chat-1.1.umd.js

Check [release notes](RELEASE.md) for details
5 changes: 0 additions & 5 deletions RELEASE.md

This file was deleted.

4 changes: 3 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
}
</style>

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<!-- Include this javscript -->
<script src="https://d1fmfone96g0x2.cloudfront.net/tarka-chat-2.0.2.umd.js"></script>
<script src="https://d1fmfone96g0x2.cloudfront.net/tarka-chat-2.2.1.umd.js"></script>
</head>
<body>
<div class="container">
Expand Down
2 changes: 2 additions & 0 deletions dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<title>TarkaChat DevMode</title>
</head>
<body>
Expand Down
91 changes: 85 additions & 6 deletions dev/init.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import TarkaChat from "../src/main.js";
import "./style.css"
import "./style.css";

const UPLOAD_TYPES = ["image/png", "image/jpeg"];

function generateImageThumbnail(file) {
return new Promise((resolve) => {
const reader = new FileReader();
reader.onload = function (e) {
const thumbnail = document.createElement("img");
thumbnail.src = e.target.result;
thumbnail.alt = file.name;
resolve(thumbnail);
};
reader.readAsDataURL(file);
});
}

function getPreChatScreen(onClose) {
const title = document.createElement("h3");
Expand All @@ -16,11 +31,73 @@ function getPreChatScreen(onClose) {
return container;
}

async function sendMessage(message) {
async function sendMessage(message, optionalFiles) {
console.log(optionalFiles);
// Do API calls
await new Promise((resolve) => setTimeout(resolve, 3000));
// after getting response
return Promise.resolve("Recieved: " + message);
await new Promise((resolve) => setTimeout(resolve, 1000));

// after getting response use any one of the following to simulate different types of responses
let textResponse =
"This is a **markdown** __enabled__ text response \n * First \n * Second";
let textObjResponse = { type: "text", message: "hi tehreee" };
let fileObjResponse = {
type: "file",
name: "tarka trends",
link: "https://tarkalabs.com",
};
let imageObjResponse = {
type: "image",
name: "tarka logo",
link: "https://tarkalabs.com/assets/img/teamg2.94f91078.jpg",
};
let tableObjResponse = {
type: "table",
table_data: {
header: ["col1", "col2"],
rows: [
{ col1: "a", col2: 1 },
{ col1: "b", col2: 2 },
],
},
};
let blankTableObjResponse = {
type: "table",
table_data: {
header: ["col1", "col2"],
rows: [],
},
};
let highchartsResponse = {
type: "highchart-config",
high_chart_config: {
chart: {
type: "pie",
},
title: {
text: "Browsers market share",
},
series: [
{
name: "Brands",
data: [
{
name: "Chrome",
y: 70,
},
{
name: "Firefox",
y: 20,
},
{
name: "Others",
y: 10,
},
],
},
],
},
};
return Promise.resolve(textResponse);
}

const chat = TarkaChat.init({
Expand All @@ -29,9 +106,11 @@ const chat = TarkaChat.init({
greeting: "Hello. How can I assist you today?",
themeColor: "#F0DAFB",
selectorId: "tarkachatbot",
uploadTypes: UPLOAD_TYPES,
generateUploadPreview: generateImageThumbnail,
preChatRenderer: getPreChatScreen,
submitHandler: sendMessage,
expand: true,
});

// chat.toggle(), chat.isOpen()
// chat.toggle(), chat.isOpen()
Loading
Loading