Skip to content

Commit

Permalink
feat: simplify local development workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
effervescentia committed Jul 14, 2023
1 parent 7aea14f commit d4037a9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,26 @@ Example call:
```ts
window.voiceflow.chat.show();
```

## Running Locally

To run the chat locally you will need to create a local `.env` file with your configuration.
This will include our Voiceflow project ID and the runtime endpoint.

Create a new file `packages/widget/.env.development.local` with the following contents:

```sh
VITE_VF_PROJECT_ID='< your project ID >'
VITE_VF_RUNTIME_URL='https://general-runtime.voiceflow.com'

```

Now that the chat is configured, let's install dependencies and run the development server.

```sh
yarn install

yarn dev
```

Once the server is running it should automatically open your browser with the chat widget.
3 changes: 2 additions & 1 deletion packages/widget/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# THIS IS A PUBLIC FILE, THIS WILL BE COMMITTED TO GITHUB

VITE_WIDGET_URL='http://127.0.0.1:3006'
VITE_WIDGET_URL='http://127.0.0.1:3006'
VITE_VF_RUNTIME_URL='https://general-runtime.development.voiceflow.com'
2 changes: 2 additions & 0 deletions packages/widget/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env.local
.env.*.local
4 changes: 2 additions & 2 deletions packages/widget/examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<script>
function _vf_load() {
window.voiceflow.chat.load({
url: 'https://general-runtime.development.voiceflow.com',
verify: { projectID: 'xxx-123-xxx-456' },
url: process.env.VITE_VF_RUNTIME_URL,
verify: { projectID: process.env.VITE_VF_PROJECT_ID },
user: {
name: 'Development User',
},
Expand Down
2 changes: 2 additions & 0 deletions packages/widget/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export default defineConfig(({ mode }) => {
define: {
'process.env': {
VITE_WIDGET_URL,
VITE_VF_PROJECT_ID: env.VITE_VF_PROJECT_ID,
VITE_VF_RUNTIME_URL: env.VITE_VF_RUNTIME_URL,
},
},
build: {
Expand Down

0 comments on commit d4037a9

Please sign in to comment.