Skip to content

Commit 595aaea

Browse files
Merge pull request #1 from VapiAI/master
Sync master to main
2 parents 9d85446 + 58bcf8f commit 595aaea

File tree

8 files changed

+2148
-1752
lines changed

8 files changed

+2148
-1752
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ dist-ssr
2525

2626
public/assets
2727
.vercel
28+
.env

README.md

Lines changed: 64 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,33 @@ This project integrates the Vapi client into any website, providing a voice assi
1515
To add Vapi to your website, include the following javascript snippet in your HTML file inside a script tag:
1616

1717
```js
18-
(function (d, t) {
19-
var g = document.createElement(t),
20-
s = d.getElementsByTagName(t)[0];
21-
g.src =
22-
"https://cdn.jsdelivr.net/gh/VapiAI/vapi-support-sdk/dist/assets/index.js";
23-
g.defer = true;
24-
g.async = true;
25-
s.parentNode.insertBefore(g, s);
26-
27-
g.onload = function () {
28-
window.vapiSDK.run({
29-
apiKey: "",
30-
assistant: assistant,
31-
position: "bottom",
32-
color: `rgb(93, 254, 202)`,
33-
offset: "40px",
34-
});
35-
};
36-
})(document, "script");
18+
<script>
19+
(function (d, t) {
20+
var g = document.createElement(t),
21+
s = d.getElementsByTagName(t)[0];
22+
g.src =
23+
"https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag/dist/assets/index.js";
24+
g.defer = true;
25+
g.async = true;
26+
s.parentNode.insertBefore(g, s);
27+
28+
g.onload = function () {
29+
const vapi = window.vapiSDK.run({
30+
apiKey: "", // required
31+
assistant: assistant, // required
32+
config: buttonConfig // optional
33+
});
34+
35+
if(vapi) {
36+
// Extend more using vapi
37+
38+
}
39+
};
40+
})(document, "script");
41+
</script>
3742
```
3843

39-
Sample assistant config is
44+
Where value of assistant can be your assistant ID (Dashboard > Assistants > Select your assistant > Copy the id) or assistant config like below example.
4045

4146
```js
4247
const assistant = {
@@ -54,6 +59,42 @@ const assistant = {
5459
};
5560
```
5661

62+
You can also customise the look and feel of your Vapi Support Button using the following configurations.
63+
The button will have 3 states, `idle`, `loading` and `active`.
64+
65+
```js
66+
const buttonConfig = {
67+
position: "bottom-right", // "bottom" | "top" | "left" | "right" | "top-right" | "top-left" | "bottom-left" | "bottom-right"
68+
offset: "40px", // decide how far the button should be from the edge
69+
width: "50px", // min-width of the button
70+
height: "50px", // height of the button
71+
idle: {
72+
// button state when the call is not active.
73+
color: `rgb(93, 254, 202)`,
74+
type: "pill", // or "round"
75+
title: "Have a quick question?", // only required in case of Pill
76+
subtitle: "Talk with our AI assistant", // only required in case of pill
77+
icon: `https://unpkg.com/[email protected]/icons/phone.svg`,
78+
},
79+
loading: {
80+
// button state when the call is connecting
81+
color: `rgb(93, 124, 202)`,
82+
type: "pill", // or "round"
83+
title: "Connecting...", // only required in case of Pill
84+
subtitle: "Please wait", // only required in case of pill
85+
icon: `https://unpkg.com/[email protected]/icons/loader-2.svg`,
86+
},
87+
active: {
88+
// button state when the call is in progress or active.
89+
color: `rgb(255, 0, 0)`,
90+
type: "pill", // or "round"
91+
title: "Call is in progress...", // only required in case of Pill
92+
subtitle: "End the call.", // only required in case of pill
93+
icon: `https://unpkg.com/[email protected]/icons/phone-off.svg`,
94+
},
95+
};
96+
```
97+
5798
## Configuration
5899

59100
You can customize the assistant by modifying the `assistant` object. The `apiKey` should be replaced with your unique key provided by Vapi.
@@ -63,9 +104,12 @@ You can customize the assistant by modifying the `assistant` object. The `apiKey
63104
The SDK exposes several CSS classes that can be targeted for custom styling. Here is a list of the classes you can customize:
64105

65106
- `.vapi-btn`: The main class for the Vapi button.
107+
- `.vapi-btn-is-idle`: The class for the Vapi button when the call is disconnected.
66108
- `.vapi-btn-is-active`: The class for the Vapi button when the call is active.
67109
- `.vapi-btn-is-loading`: The class for the Vapi button when the call is connecting.
68110
- `.vapi-btn-is-speaking`: The class for the Vapi button when the bot is speaking.
111+
- `.vapi-btn-pill`: The class for Vapi button to set pill variant.
112+
- `.vapi-btn-round`: The class for Vapi button to set round variant.
69113

70114
You can add custom styles to these classes to match the look and feel of your website. These are exposed in case u need some more customisations besides the `position`, `color` and `offset` config available currently.
71115

0 commit comments

Comments
 (0)