> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vzaps.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeBot

> Configure TypeBot and manage sessions with the Go SDK

Use `client.Typebots` to integrate TypeBot flows with a VZaps instance.

Common fields on every call:

| Field           | Type     | Required | Description     |
| --------------- | -------- | -------- | --------------- |
| `InstanceID`    | `string` | Yes      | Instance ID.    |
| `InstanceToken` | `string` | Yes      | Instance token. |

## `Typebots.List(ctx, instanceID, options)`

Lists TypeBots configured on the instance.

```go theme={null}
typebots, err := client.Typebots.List(ctx, "VZ...", vzaps.InstanceOptions{
	InstanceToken: "instance-token",
})
fmt.Printf("%#v\n", typebots)
```

**Return:** array of TypeBot configs for the instance (IDs, triggers, priority, etc.).

## `Typebots.Create(ctx, req)`

Creates a TypeBot configuration.

```go theme={null}
created, err := client.Typebots.Create(ctx, vzaps.TypebotRequest{
	InstanceScopedRequest: vzaps.InstanceScopedRequest{
		InstanceID:    "VZ...",
		InstanceToken: "instance-token",
	},
	Enabled:         true,
	Description:     "Welcome flow",
	TypebotURL:      "https://typebot.io",
	PublicID:        "my-public-flow",
	TriggerType:     "keyword",
	TriggerValue:    "hello",
	Priority:        10,
	ExpireInMinutes: 30,
	KeywordFinish:   "exit",
	DefaultDelayMs:  800,
	UnknownMessage:  "Sorry, I did not understand. Can you rephrase?",
	TranscribeAudio: true,
	ListenFromMe:    false,
	StopBotFromMe:   true,
	KeepOpen:        false,
	DebounceMs:      1500,
	IgnoreGroups:    false,
})
fmt.Printf("%#v\n", created)
```

**Return:** created config, including `typebot_id` for later updates.

Main payload fields:

| Field (JSON)        | Go field          | Required    | Description                                                                  |
| ------------------- | ----------------- | ----------- | ---------------------------------------------------------------------------- |
| `enabled`           | `Enabled`         | Yes         | Enables or disables trigger evaluation.                                      |
| `description`       | `Description`     | Yes         | Display name for the configuration.                                          |
| `typebot_url`       | `TypebotURL`      | Yes         | TypeBot base URL.                                                            |
| `public_id`         | `PublicID`        | Yes         | Public flow identifier.                                                      |
| `trigger_type`      | `TriggerType`     | Yes         | `all`, `keyword`, `contains`, `starts_with`, `regex`, `advanced`, or `none`. |
| `trigger_value`     | `TriggerValue`    | Conditional | Trigger text or regex.                                                       |
| `trigger_operator`  | `TriggerOperator` | Conditional | Used when `TriggerType` is `advanced`.                                       |
| `priority`          | `Priority`        | Yes         | Evaluation order. Higher value first.                                        |
| `expire_in_minutes` | `ExpireInMinutes` | Yes         | Session expiry after inactivity. `0` means no expiry.                        |

## `Typebots.Update(ctx, req)`

Updates an existing TypeBot. Pass `TypebotID` from create or list.

```go theme={null}
_, err := client.Typebots.Update(ctx, vzaps.TypebotMutationRequest{
	TypebotRequest: vzaps.TypebotRequest{
		InstanceScopedRequest: vzaps.InstanceScopedRequest{
			InstanceID:    "VZ...",
			InstanceToken: "instance-token",
		},
		Enabled:         true,
		Description:     "Updated welcome flow",
		TriggerType:     "contains",
		TriggerValue:    "help",
		Priority:        20,
		ExpireInMinutes: 60,
	},
	TypebotID: "550e8400-e29b-41d4-a716-446655440000",
})
```

**Return:** updated config or `{ status: "ok" }`.

## `Typebots.Delete(ctx, req)`

Removes the configuration and its sessions.

```go theme={null}
_, err := client.Typebots.Delete(ctx, vzaps.TypebotMutationRequest{
	TypebotRequest: vzaps.TypebotRequest{
		InstanceScopedRequest: vzaps.InstanceScopedRequest{
			InstanceID:    "VZ...",
			InstanceToken: "instance-token",
		},
	},
	TypebotID: "550e8400-e29b-41d4-a716-446655440000",
})
```

**Return:** deletion confirmation (`{ status: "ok" }` or equivalent message).

## `Typebots.StartSession(ctx, req)`

Starts a session manually with a contact.

By `PublicID`:

```go theme={null}
_, err := client.Typebots.StartSession(ctx, vzaps.TypebotStartSessionRequest{
	InstanceScopedRequest: vzaps.InstanceScopedRequest{
		InstanceID:    "VZ...",
		InstanceToken: "instance-token",
	},
	PublicID:  "support",
	Phone:     "5511999999999",
	PushName:  "Customer",
	Message:   "I need help",
})
```

**Return:** started session (session UUID, contact, `opened` status).

By `TypebotID`:

```go theme={null}
_, err := client.Typebots.StartSession(ctx, vzaps.TypebotStartSessionRequest{
	InstanceScopedRequest: vzaps.InstanceScopedRequest{
		InstanceID:    "VZ...",
		InstanceToken: "instance-token",
	},
	TypebotID: "550e8400-e29b-41d4-a716-446655440000",
	Phone:     "5511999999999",
	Message:   "I need help",
})
```

| Field (JSON) | Go field    | Required    | Description                                            |
| ------------ | ----------- | ----------- | ------------------------------------------------------ |
| `public_id`  | `PublicID`  | Conditional | Public flow identifier. Use `PublicID` or `TypebotID`. |
| `typebot_id` | `TypebotID` | Conditional | Internal TypeBot ID.                                   |
| `phone`      | `Phone`     | Yes         | Contact phone.                                         |
| `message`    | `Message`   | Yes         | Initial message sent to the flow.                      |
| `push_name`  | `PushName`  | No          | Contact display name.                                  |

## `Typebots.ListSessions(ctx, instanceID, options)`

Lists active and closed sessions.

```go theme={null}
sessions, err := client.Typebots.ListSessions(ctx, "VZ...", vzaps.InstanceOptions{
	InstanceToken: "instance-token",
})
fmt.Printf("%#v\n", sessions)
```

**Return:** session list (`opened`, `paused`, `closed`) per contact/flow.

## `Typebots.PauseSession(ctx, req)`

Pauses an open session. Pass the session UUID in `Session`.

```go theme={null}
_, err := client.Typebots.PauseSession(ctx, vzaps.TypebotSessionRequest{
	InstanceScopedRequest: vzaps.InstanceScopedRequest{
		InstanceID:    "VZ...",
		InstanceToken: "instance-token",
	},
	Session: "550e8400-e29b-41d4-a716-446655440001",
})
```

**Return:** session with `paused` status.

## `Typebots.CloseSession(ctx, req)`

Closes a session manually.

By session UUID:

```go theme={null}
_, err := client.Typebots.CloseSession(ctx, vzaps.TypebotSessionRequest{
	InstanceScopedRequest: vzaps.InstanceScopedRequest{
		InstanceID:    "VZ...",
		InstanceToken: "instance-token",
	},
	Session: "550e8400-e29b-41d4-a716-446655440001",
})
```

**Return:** closed session or confirmation by phone number.

By contact phone (closes all active sessions for that number):

```go theme={null}
_, err := client.Typebots.CloseSession(ctx, vzaps.TypebotSessionRequest{
	InstanceScopedRequest: vzaps.InstanceScopedRequest{
		InstanceID:    "VZ...",
		InstanceToken: "instance-token",
	},
	Session: "5511999999999",
})
```
