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

Release new demo app and SDK improvements. #119

Merged
merged 38 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fc6d6da
Host demo app on GitHub Pages
esme Feb 13, 2023
1d2a58f
Create demo app UI using React and TS (#63)
esme Feb 14, 2023
9e6f1da
Deploy demo apps to GH pages (#65)
esme Feb 15, 2023
4f387c3
Setup a testing suite for the demo app (#68)
esme Feb 23, 2023
3d51c44
Run test:serve with --watch
esme Feb 24, 2023
d85889c
Add minimal phone number validation to keypad (#71)
esme Feb 27, 2023
681a3cb
Update event console logging (#70)
esme Mar 2, 2023
b79ed14
Demo console banner (#78)
esme Mar 2, 2023
2d085d0
Send additional call engagement properties in callCompletedData (#79)
esme Mar 7, 2023
083e7f8
Demo app icons (#84)
esme Mar 8, 2023
6ea6276
Deploy from build folder
esme Mar 8, 2023
f863b7a
Add keypad to call actions
esme Mar 8, 2023
195e74c
Backfill unit tests (#86)
esme Mar 16, 2023
a7de454
Fix after rebase
esme Mar 16, 2023
20648a7
Offer both demo apps (#88)
esme Mar 21, 2023
bcad771
Add fake number to the From Numbers dropdown (#93)
esme Mar 28, 2023
ffdb744
Update demos to use latest sdk package version (#96)
alonso-cadenas Apr 7, 2023
7ed9d80
Organize NPM scripts in the demo app (#95)
esme Apr 7, 2023
8528435
Merge changes from master branch (#102)
esme Apr 12, 2023
f221873
Demo readme (#104)
esme Apr 17, 2023
9001655
Publish new alpha version (#105)
esme Apr 17, 2023
4c66740
Rename demo widgets (#106)
esme Apr 19, 2023
dc79360
Fix demo app build warnings and iFrame uninitialized message (#107)
esme Apr 20, 2023
c981b36
Merge remote-tracking branch 'origin/master' into project-demo-v1
esme Apr 25, 2023
43b4dad
Send callStartTime in outgoingCall message (#108)
esme Apr 25, 2023
bb439e1
Specify minimum required Node.js version (#109)
esme Apr 26, 2023
f215426
Remove demo folder
esme Apr 26, 2023
bc6eb96
Update webpack config to serve static files from the public directory…
esme May 1, 2023
9e6ced3
Enforce order of events in demo minimal js (#113)
esme May 8, 2023
5d3fcad
Merge remote-tracking branch 'origin/master' into project-demo-v1
alonso-cadenas May 10, 2023
d186609
Finalize new demo app documentation (#115)
alonso-cadenas May 10, 2023
b922e4a
Use new local value to install the demo widget (#117)
alonso-cadenas May 16, 2023
b4e3e4a
Fix spacing
alonso-cadenas May 16, 2023
f3a47b6
Add ability to publish prerelease versions to npm (#118)
alonso-cadenas May 18, 2023
4c8143b
0.1.0
alonso-cadenas May 22, 2023
d46ffd3
Enable github actions (#120)
alonso-cadenas May 22, 2023
2d8b881
Update demo documentation (#121)
alonso-cadenas May 22, 2023
aef77dd
test gha (#124)
alonso-cadenas May 22, 2023
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
27 changes: 27 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Deploy demo apps to GH Pages
concurrency: ci-${{ github.ref }}
on:
workflow_dispatch:
push:
branches: [project-demo-v1]
alonso-cadenas marked this conversation as resolved.
Show resolved Hide resolved

defaults:
run:
working-directory: demos

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v3
- name: Install and build 🔧
run: npm run build:gh
- name: Run tests ✅
run: npm run test
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: demos/build
branch: gh-pages
clean-exclude: pr-preview
29 changes: 29 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy PR previews for demo apps
run-name: ${{ github.actor }} is deploying a PR
concurrency: preview-${{ github.ref }}
on:
workflow_dispatch:
pull_request:
branches: ['*demo*']
alonso-cadenas marked this conversation as resolved.
Show resolved Hide resolved

defaults:
run:
working-directory: demos

jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v3
- name: Install and build 🔧
run: npm run build:gh
- name: Run tests ✅
run: npm run test
- name: Deploy preview 🚀
uses: rossjrw/pr-preview-action@v1.3.0
with:
source-dir: demos/build
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
node_modules
npm-debug.log
dist
bin
*.pem
coverage
build
.DS_STORE
lib
demos/build/*
!demos/build/.gitkeep
dist-test
1 change: 0 additions & 1 deletion .node-version

This file was deleted.

119 changes: 90 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Calling Extensions SDK enables 3rd party VOIP providers or enterprise calling sy
## Getting Started

1. [Create a HubSpot app](https://developers.hubspot.com/docs/faq/how-do-i-create-an-app-in-hubspot) and [create a test account](https://developers.hubspot.com/docs/faq/how-do-i-create-a-test-account).
2. [Install](https://github.com/HubSpot/calling-extensions-sdk#install-the-calling-extensions-sdk-on-your-call-widget) the Calling Extensions SDK on your call widget. Alternatively, you can [run the demo call widget](https://github.com/hubspot/calling-extensions-sdk#run-the-demo-call-widget) if you'd like to see the SDK in action first.
2. [Install](https://github.com/HubSpot/calling-extensions-sdk#install-the-calling-extensions-sdk-on-your-call-widget) the Calling Extensions SDK on your call widget. Alternatively, you can [run the demos](https://github.com/hubspot/calling-extensions-sdk#run-the-demos) if you'd like to see the SDK in action first.
3. Understand the [typical message flow between the call widget and HubSpot](https://github.com/HubSpot/calling-extensions-sdk#typical-message-flow-between-the-call-widget-and-hubspot).
4. Learn how to [use the Calling Extensions SDK](https://github.com/hubspot/calling-extensions-sdk#using-the-calling-extensions-sdk).
5. [Test](https://github.com/HubSpot/calling-extensions-sdk#test-your-app-from-a-local-environment) your app from a local environment.
Expand All @@ -27,37 +27,50 @@ npm i --save @hubspot/calling-extensions-sdk
```shell
yarn add @hubspot/calling-extensions-sdk
```
## Run the Demo Call Widget
## Run the Demos

We have installed the SDK on a demo call widget as an example.
We have installed the SDK on two demo apps to serve as examples:
- The [demo-minimal-js](https://github.com/HubSpot/calling-extensions-sdk/tree/project-demo-v1/demos/demo-minimal-js) features a minimal implementation of the SDK using JavaScript, HTML, and CSS. View how the SDK is instantiated in [index.js](https://github.com/HubSpot/calling-extensions-sdk/blob/project-demo-v1/demos/demo-minimal-js/index.js).
- The [demo-react-ts](https://github.com/HubSpot/calling-extensions-sdk/tree/project-demo-v1/demos/demo-react-ts) features a real-life implementation of the SDK using React, TypeScript, and Styled Components. Use it as a blueprint for your app! View how the SDK is instantiated in [useCti.ts](https://github.com/HubSpot/calling-extensions-sdk/blob/project-demo-v1/demos/demo-react-ts/src/hooks/useCti.ts).

Note that these demos aren't fully functional calling apps and use mock data to provide a more realistic experience.

### Installation
1. Download the demo call widget by cloning/forking this repo or by [downloading the ZIP](https://github.com/HubSpot/calling-extensions-sdk/archive/refs/heads/master.zip).
2. In your terminal, locate the root directory of the project, then navigate to the demo directory by running:
```shell
cd demo
```
3. Install the project's [Node.js](https://nodejs.org/en/) dependencies using the [npm CLI](https://docs.npmjs.com/cli/v9) by running:
```shell
npm i
```
4. Start the demo app on your browser by running:
```shell
npm start
```
This command will open a new tab at https://localhost:9025/. Note that you may need bypass a "Your connection is not secure" warning in order to access the application.

Install these demos on your local environment using the following steps, or skip to the next section to run the demos without installation.
1. Ensure that you have installed [Node.js](https://nodejs.org/en/) on your environment.
2. Clone, fork, or download the ZIP of this repository.
3. Open your terminal, navigate to the root directory of the project, and run one of the following commands:
- For the `demo-minimal-js`:
```shell
cd demos/demo-minimal-js && npm i && npm start
```
- For the `demo-react-ts`:
```shell
cd demos/demo-react-ts && npm i && npm start
```
These will switch to the desired demo directory, install the [Node.js](https://nodejs.org/en/) dependencies required for the project using the [npm CLI](https://docs.npmjs.com/cli/v9), and start the app. Note that the `npm start` command will automatically open a new tab in your browser at https://localhost:9025/, and you may need bypass a "Your connection is not secure" warning in order to access the application.


### Launch the demo call widget from HubSpot
1. In HubSpot, navigate to a contact or company page.
2. Open the browser's developer console and paste the following:
```js
localStorage.setItem(
"LocalSettings:Calling:CallingExtensions",
'{"name": "Demo widget", "url": "https://localhost:9025/"}'
);
```

1. Navigate to a contact or company page within your HubSpot account.
2. Open your browser's developer console, and run one of the following:
- If you've installed the `demo-minimal-js` or the `demo-react-ts`:
```js
localStorage.setItem("LocalSettings:Calling:installDemoWidget", "local");
```
- If you've skipped the installation steps, run one of the following:
- For the `demo-minimal-js`:
```js
localStorage.setItem("LocalSettings:Calling:installDemoWidget", "app:js");
```
- For the `demo-react-ts`:
```js
localStorage.setItem("LocalSettings:Calling:installDemoWidget", "app");
```
3. Refresh the page and click the "Make a phone call" button on the left toolbar to open the calling settings popover.
4. In the calling settings popover, click on "Open call options" then select the "Demo widget" under the Calling Provider options.
4. In the calling settings popover, click on "Open call options", locate the Calling Provider options, and select the name of the widget from step #2 ("Demo Widget Local", "Demo Widget JS", or "Demo Widget React").
5. You can now click on the "Call" button to see how the demo widget integrates with HubSpot via the Calling Extensions SDK. You can also see the events logged to your browser's developer console!

## Typical message flow between the call widget and HubSpot
Expand Down Expand Up @@ -183,7 +196,8 @@ extensions.userLoggedOut();

const callInfo = {
phoneNumber: string, // optional unless call is initiated by the widget
createEngagement: true // whether HubSpot should create an engagement for this call
createEngagement: true, // whether HubSpot should create an engagement for this call
callStartTime: number // optional unless call is initiated by the widget
};
extensions.outgoingCall(callInfo);
```
Expand Down Expand Up @@ -237,8 +251,54 @@ extensions.callCompleted(data);
</p>
</details>

<details>
<summary>sendError</summary>
<p>

```js
// Sends a message to notify HubSpot that the call widget has encountered an error.
// After receiving the sendError event, HubSpot will display an alert popup to the user with the error message provided.
const data = {
message: string // error message to be displayed in the alert popup
};
extensions.sendError(data);
```

</p>
</details>

<details>
<summary>resizeWidget</summary>
<p>

```js
// Sends a message to notify HubSpot that the call widget needs to be resized.
// After receiving the resizeWidget event, HubSpot will use the provided height and width to resize the call widget.
const data = {
height: boolean // desired height of the call widget
width: number, // desired width of the call widget
};
extensions.resizeWidget(data);
```

</p>
</details>

### Receiving messages from HubSpot

<details>
<summary>onReady</summary>
<p>

```js
// Message indicating that HubSpot is ready to receive messages
onReady() {
// Send initialized message to HubSpot to indicate that the call widget is also ready
extensions.initialized(payload);
...
}
```

</p>
</details>

Expand Down Expand Up @@ -362,11 +422,11 @@ The isReady flag indicate whether the widget is ready for production. This flag

```js
/**
* Override the isReady flag for the "Demo widget"
* Override the isReady flag for the call widget
*/
localStorage.setItem(
"LocalSettings:Calling:CallingExtensions",
'{"name": "Demo widget", "isReady": true}'
'{"name": "<your intended widget name>", "isReady": true}'
);
```

Expand Down Expand Up @@ -479,6 +539,7 @@ outgoingCall({ createEngagement: true })
const callInfo = {
phoneNumber: string, // optional unless call is initiated by the widget
createEngagement: true // whether HubSpot should create an engagement for this call
callStartTime: number // optional unless call is initiated by the widget
};
extensions.outgoingCall(callInfo);
```
Expand Down
1 change: 0 additions & 1 deletion demo/.node-version

This file was deleted.

57 changes: 0 additions & 57 deletions demo/index.html

This file was deleted.

Loading