Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
go-version: stable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
args: --timeout=5m
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ agent.vf
analytics.json
query.json
voiceflow-cli/choco
test.yaml
test.yaml

file.json
test_*.yaml
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ archives:
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
formats: [ 'zip' ]
builds_info:
group: root
owner: root
Expand Down
29 changes: 29 additions & 0 deletions cmd/dialog/dialog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dialog

import (
"os"

"github.com/spf13/cobra"
"github.com/xavidop/voiceflow-cli/cmd/cmdutils"
)

// DialogCmd represents the dialog command
var dialogCmd = &cobra.Command{
Use: "dialog",
Short: "Start a dialog with the Voiceflow project",
Run: func(cmd *cobra.Command, args []string) {
if err := cmd.Help(); err != nil {
os.Exit(1)
}
os.Exit(0)
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
cmdutils.PreRun(cmd.Name())
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
},
}

func Register(rootCmd *cobra.Command) {
rootCmd.AddCommand(dialogCmd)
}
43 changes: 43 additions & 0 deletions cmd/dialog/replay.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package dialog

import (
"os"

"github.com/spf13/cobra"
"github.com/xavidop/voiceflow-cli/cmd/cmdutils"
"github.com/xavidop/voiceflow-cli/internal/global"
"github.com/xavidop/voiceflow-cli/internal/voiceflow"
"github.com/xavidop/voiceflow-cli/pkg/dialog"
)

// replayCmd represents the replay command
var replayCmd = &cobra.Command{
Use: "replay",
Short: "Replay a dialog with the Voiceflow project",
Run: func(cmd *cobra.Command, args []string) {
voiceflow.SetVoiceflowAPIKey()
userID, _ := cmd.Flags().GetString("user-id")
recordFile, _ := cmd.Flags().GetString("record-file")
environment, _ := cmd.Flags().GetString("environment")

// Not check in development
if err := dialog.Replay(userID, environment, recordFile); err != nil {
global.Log.Errorf("%s", err.Error())
os.Exit(1)
}
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
cmdutils.PreRun(cmd.Name())
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
},
}

func init() {
dialogCmd.AddCommand(replayCmd)

replayCmd.Flags().StringP("user-id", "r", "", "User ID for the dialog (optional)")
replayCmd.Flags().StringP("record-file", "f", "", "Record file to use (required)")
replayCmd.Flags().StringP("environment", "e", "development", "Environment to use (optional). Default to development")

}
44 changes: 44 additions & 0 deletions cmd/dialog/start.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package dialog

import (
"os"

"github.com/spf13/cobra"
"github.com/xavidop/voiceflow-cli/cmd/cmdutils"
"github.com/xavidop/voiceflow-cli/internal/global"
"github.com/xavidop/voiceflow-cli/internal/voiceflow"
"github.com/xavidop/voiceflow-cli/pkg/dialog"
)

// StartCmd represents the start command
var startCmd = &cobra.Command{
Use: "start",
Short: "Start a dialog with the Voiceflow project",
Run: func(cmd *cobra.Command, args []string) {
voiceflow.SetVoiceflowAPIKey()
userID, _ := cmd.Flags().GetString("user-id")
recordFile, _ := cmd.Flags().GetString("record-file")
environment, _ := cmd.Flags().GetString("environment")
saveTest, _ := cmd.Flags().GetBool("save-as-test")

// Not check in development
if err := dialog.Start(userID, environment, recordFile, saveTest); err != nil {
global.Log.Errorf("%s", err.Error())
os.Exit(1)
}
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
cmdutils.PreRun(cmd.Name())
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
},
}

func init() {
dialogCmd.AddCommand(startCmd)

startCmd.Flags().StringP("user-id", "r", "", "User ID for the dialog (optional)")
startCmd.Flags().StringP("record-file", "f", "", "Record file to use (optional)")
startCmd.Flags().StringP("environment", "e", "development", "Environment to use (optional). Default to development")
startCmd.Flags().BoolP("save-as-test", "t", false, "Save conversation as a test (optional)")
}
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/xavidop/voiceflow-cli/cmd/agent"
"github.com/xavidop/voiceflow-cli/cmd/analytics"
"github.com/xavidop/voiceflow-cli/cmd/cmdutils"
"github.com/xavidop/voiceflow-cli/cmd/dialog"
"github.com/xavidop/voiceflow-cli/cmd/document"
"github.com/xavidop/voiceflow-cli/cmd/kb"
test "github.com/xavidop/voiceflow-cli/cmd/test"
Expand Down Expand Up @@ -61,6 +62,7 @@ func init() {
agent.Register(rootCmd)
kb.Register(rootCmd)
document.Register(rootCmd)
dialog.Register(rootCmd)

// Add the subcommands
rootCmd.PersistentFlags().BoolVarP(&global.Verbose, "verbose", "v", false, "verbose error output (with stack trace) (optional)")
Expand Down
1 change: 1 addition & 0 deletions docs/docs/cmd/voiceflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ voiceflow [flags]
* [voiceflow agent](/cmd/voiceflow_agent/) - Actions on agents
* [voiceflow analytics](/cmd/voiceflow_analytics/) - Actions on analytics
* [voiceflow completion](/cmd/voiceflow_completion/) - Generate the autocompletion script for the specified shell
* [voiceflow dialog](/cmd/voiceflow_dialog/) - Start a dialog with the Voiceflow project
* [voiceflow document](/cmd/voiceflow_document/) - Actions on documents
* [voiceflow jsonschema](/cmd/voiceflow_jsonschema/) - outputs voiceflow's JSON schema
* [voiceflow kb](/cmd/voiceflow_kb/) - Actions on knowledge base
Expand Down
31 changes: 31 additions & 0 deletions docs/docs/cmd/voiceflow_dialog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# voiceflow dialog

Start a dialog with the Voiceflow project

```
voiceflow dialog [flags]
```

## Options

```
-h, --help help for dialog
```

## Options inherited from parent commands

```
-z, --open-api-key string Open API Key (optional)
-o, --output-format string Output Format. Options: text, json. Default: text (optional) (default "text")
-u, --skip-update-check Skip the check for updates check run before every command (optional)
-v, --verbose verbose error output (with stack trace) (optional)
-x, --voiceflow-api-key string Voiceflow API Key (optional)
-b, --voiceflow-subdomain string Voiceflow Base URL (optional). Default: empty
```

## See also

* [voiceflow](/cmd/voiceflow/) - Voiceflow CLI
* [voiceflow dialog replay](/cmd/voiceflow_dialog_replay/) - Replay a dialog with the Voiceflow project
* [voiceflow dialog start](/cmd/voiceflow_dialog_start/) - Start a dialog with the Voiceflow project

32 changes: 32 additions & 0 deletions docs/docs/cmd/voiceflow_dialog_replay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# voiceflow dialog replay

Replay a dialog with the Voiceflow project

```
voiceflow dialog replay [flags]
```

## Options

```
-e, --environment string Environment to use (optional). Default to development (default "development")
-h, --help help for replay
-f, --record-file string Record file to use (required)
-r, --user-id string User ID for the dialog (optional)
```

## Options inherited from parent commands

```
-z, --open-api-key string Open API Key (optional)
-o, --output-format string Output Format. Options: text, json. Default: text (optional) (default "text")
-u, --skip-update-check Skip the check for updates check run before every command (optional)
-v, --verbose verbose error output (with stack trace) (optional)
-x, --voiceflow-api-key string Voiceflow API Key (optional)
-b, --voiceflow-subdomain string Voiceflow Base URL (optional). Default: empty
```

## See also

* [voiceflow dialog](/cmd/voiceflow_dialog/) - Start a dialog with the Voiceflow project

33 changes: 33 additions & 0 deletions docs/docs/cmd/voiceflow_dialog_start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# voiceflow dialog start

Start a dialog with the Voiceflow project

```
voiceflow dialog start [flags]
```

## Options

```
-e, --environment string Environment to use (optional). Default to development (default "development")
-h, --help help for start
-f, --record-file string Record file to use (optional)
-t, --save-as-test Save conversation as a test (optional)
-r, --user-id string User ID for the dialog (optional)
```

## Options inherited from parent commands

```
-z, --open-api-key string Open API Key (optional)
-o, --output-format string Output Format. Options: text, json. Default: text (optional) (default "text")
-u, --skip-update-check Skip the check for updates check run before every command (optional)
-v, --verbose verbose error output (with stack trace) (optional)
-x, --voiceflow-api-key string Voiceflow API Key (optional)
-b, --voiceflow-subdomain string Voiceflow Base URL (optional). Default: empty
```

## See also

* [voiceflow dialog](/cmd/voiceflow_dialog/) - Start a dialog with the Voiceflow project

34 changes: 34 additions & 0 deletions docs/docs/dialog/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Dialog Commands

The `dialog` commands allow you to interact with your Voiceflow project through a conversational interface. You can start new conversations, record them for later use, replay previous conversations, and create tests from your interactions.

## Available Commands

| Command | Description |
|---------|-------------|
| [start](./start.md) | Start a new conversation with your Voiceflow project |
| [replay](./replay.md) | Replay a previously recorded conversation |

## Common Options

All dialog commands support these common options:

| Option | Description |
|--------|-------------|
| `--environment`, `-e` | Voiceflow environment to use (default: "development") |
| `--user-id`, `-u` | User ID for the conversation (optional, will generate a random ID if not provided) |

## Basic Usage

```bash
# Start a new conversation in the development environment
voiceflow dialog start

# Replay a recorded conversation
voiceflow dialog replay -f conversation.json

# Start a conversation in the production environment
voiceflow dialog start -e production
```

For detailed information about each command, refer to their specific documentation pages.
75 changes: 75 additions & 0 deletions docs/docs/dialog/replay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
sidebar_position: 2
---

# Replay Command

The `replay` command allows you to replay previously recorded conversations with your Voiceflow project. This is useful for testing changes to your project with consistent inputs, demonstrating flows, or debugging issues.

## Usage

```bash
voiceflow dialog replay -f RECORD_FILE [options]
```

## Options

| Option | Shorthand | Description |
|--------|-----------|-------------|
| `--record-file` | `-f` | Path to the recorded conversation file (required) |
| `--environment` | `-e` | Environment to use (default: "development") |
| `--user-id` | `-u` | User ID for the conversation (optional) |

## Examples

### Replay a recorded conversation

```bash
voiceflow dialog replay -f my-conversation.json
```

This will replay all interactions from the recording file against your Voiceflow project.

### Replay with a specific user ID

```bash
voiceflow dialog replay -f my-conversation.json --user-id user123
```

This allows you to maintain consistent user state or test with specific user profiles.

### Replay in production environment

```bash
voiceflow dialog replay -f my-conversation.json -e production
```

Replays the conversation using your production environment settings.

## How Replay Works

The `replay` command:

1. Reads the recorded conversation file specified with `-f`
2. Processes each interaction in sequence, automatically sending user inputs to the Voiceflow API
3. Displays the responses from your Voiceflow project for each interaction
4. Adds brief pauses between interactions to simulate natural conversation timing

## Creating Recording Files

To create a file for replay, use the `dialog start` command with the `--record-file` option:

```bash
voiceflow dialog start --record-file my-conversation.json
```

During the conversation, every interaction will be saved to the specified file. When you finish the conversation (by typing `exit` or pressing `Ctrl+C`), the complete recording will be available for replay.

## Troubleshooting

If the replay produces different results than the original conversation:

1. Check if your Voiceflow project has been modified since the recording
2. Verify you're using the same environment that was used during recording
3. Consider using a consistent user ID if your project relies on user-specific state
4. Ensure any external APIs or services your project depends on are available
Loading
Loading