Platform
APIs & SDKs
Resources

Developer CLI

Introduction

Developer CLI is a command-line tool that helps you build and modify Text applications. It provides a set of commands that you can use to create, develop, and deploy your Text apps.

With the CLI, you can:

  • Create a new Text app from scratch
  • Bootstrap our repository and app templates, for example, Next.js SaaS template
  • Add building blocks to your app without entering the Developer Console
  • Update your app by editing its manifest (livechat.config.json)

Installation

Start by installing the newest version of the Developer CLI using either npm or yarn.

Install Developer CLI using npm
Copied!
npm install -g @livechat/developer-cli

or

Install Developer CLI using yarn
Copied!
yarn global add @livechat/developer-cli

Modules

The CLI has two modules that you can use to manage your Text apps:

  • auth - authorize to the CLI and external providers
  • app - create and manage apps

💡 Run txdev --help to lists available modules and options.

App manifest

Each application in the Developer Console is represented by an app manifest (livechat.config.json). There are two ways to edit an application via CLI:

  1. Run a command from the txdev app module.

    Running a command will automatically update your app in the Developer Console. After that, pull the changes to the app manifest (txdev app pull) as it doesn't update automatically.

    We recommend this method to apply more complex changes, such as adding an enitre building block.

  2. Edit livechat.config.json manually.

    Then, run txdev app push to push the changes to the Developer Console.

    We recommend this method to apply small, quick changes, such as adding a new scope.

EXAMPLE APP MANIFEST WITH AUTH BLOCK
Copied!
{
  "id": "BgYQO_BIg",
  "name": "EmptyApp",
  "product": "livechat",
  "blocks": {
    "authorization": {
      "clientId": "5c4d731184619046c915549fb09c1561",
      "type": "server_side_app",
      "redirectUri": "https://myapp.com,https://myapp.com/settings",
      "scopes": [
        {
          "scope": "archives_read",
          "required": true
        },
        {
          "scope": "chats.conversation--my:rw",
          "required": true
        }
      ]
    }
  }
}


Not every field can be modified, for example, you can't change the value of client_id.

Application context

Most CLI commands need to be run within the context of the application you're working on. The exceptions from this rule would be txdev app create, txdev app clone or the commands from the auth module.

Working within the application context matters because the CLI automatically detectes if there's an app manifest in the working directory. If so, it uses the app ID from the manifest to execute the command. However, the CLI also allows for a more flexible approach where you can work outside of the application context by passing the app ID and working directory in the command.

Working outside of the app context

To work outside of the application context you need to provide two optional parameters when running the commands:

ParameterDescriptionDefault value
--idApp ID. The CLI will look for this app ID in the location provided in --dirfrom app manifest
--dirTells the CLI where to look for the app manifest./

For example, you can work on an app that lives in ./apps/my-app while being in a different directory (e.g. in ./).

$ txdev app verify --id=suLCxdG --dir=./apps/my-app

Getting started tutorial

This tutorial shows how to quickly add a new widget to an existing app using the Developer CLI.

1. Log in to Text Developer Console using the CLI.

1. Log in to Developer Console
Copied!
txdev auth login --provider=accounts

2. Clone an existing app to your local environment.

The CLI will prompt you to select an app.

2. Clone an app
Copied!
txdev app clone

After cloning, cd to the app directory so that you're in the same location as the livechat.config.json file. To work from a different location, see Working outside of the app context.

3. Add a new widget to the app.

The CLI will prompt you to specify the widget details such as widget placement and URL.

3. Add a widget
Copied!
txdev app widgets add

4. Update the local app manifest.

After executing a command from the app module, you need to pull the changes to your local app manifest (txdev app pull) as it doesn't update automatically.

4. Pull app manifest changes
Copied!
txdev app pull

5. See applied changes in the Developer Console.

5. Open the app in Developer Console
Copied!
txdev app open

app module

txdev app --help

Lists available command in the app module.

txdev app --help
Copied!
$ txdev app --help

Commands:
  txdev app create         create new app
  txdev app clone          clone app
  txdev app delete         delete app
  txdev app open           open app in browser
  txdev app pull           pull app manifest
  txdev app push           push app manifest
  txdev app verify         verify app manifest
  txdev app authorization  manage app authorization       
  txdev app monetization   manage app monetization        
  txdev app repository     manage app repository          
  txdev app deployment     manage app deployment          
  txdev app storage        manage app storage             
  txdev app properties     manage app properties          
  txdev app widgets        manage app widgets
  txdev app variables      manage app variables

txdev app clone

Fetches all the files related to an application registered in the Text Developer Console.

As a bare minimum, the command will fetch the app's manifest (livechat.config.json), but it can also download other files depending on what's set up for the application (repository, environment variables) in the Developer Console.

When to use the command:

  • download all files of a newly created app
  • update the app files after changes made in the Developer Console
Basic usage
Copied!
$ txdev app clone

? select app › 
❯   Moments card sender
    Get Chats App
    My app
Specifying app ID
Copied!
$ txdev app clone --id=suLCxdG-R
ParameterDescriptionDefault
--idApp ID. Specify which app from the Developer Console you want to clone locally
--dirSee Working outside of app context
--targetDirTarget location of the app files to be saved in--dir

txdev app create

Creates a new application. It can be empty or bootstrapped from our Next.js SaaS template, which comes with a variety of features already set up.

💡txdev app create template is the fastest ways to create a fully working & deployed Text application.

Basic usage - create an app from a template
Copied!
$ txdev app create template

? template › 
❯   Nextjs SaaS boilerplate
Specifying app details upon creation
Copied!
$ txdev app create empty --name="Sample app" --product=livechat
OptionParamDescription
emptyCreate an empty app. Add buidling blocks later.
--nameApp name. Required param.
--productlivechat or helpdesk. Required param.
--dirSee Working outside of app context
--targetDirTarget location of the app files to be saved in. Default value: --dir
templateCreate an app from a template. Building blocks will be added automatically.
--dirSee Working outside of app context
--targetDirTarget location of the app files to be saved in. Default value: --dir

txdev app pull

Fetches the app manifest (livechat.config.json) from the Developer Console.

This command will not pull other files related to the app. To download/update all app files, use the txdev app clone command.

Basic usage
Copied!
$ txdev app pull

? select app › 
❯   Moments card sender
    Get Chats App
    My app
Specifying app ID
Copied!
$ txdev app pull --id=suLCxdG-R
ParameterDescription
--id, --dirSee Working outside of app context
--targetDirTarget location of the app manifest to be saved in. Default value: --dir

txdev app push

Pushes local changes made to the app manifest (livechat.config.json) to the Developer Console. The command will only push changes from the app manifest.

ParameterDescription
--id, --dirSee Working outside of app context

txdev app verify

Verify your local app manifest (livechat.config.json) against the one in the Text Developer Console. It compares only the app manifest, not all app files.

ParameterDescription
--id, --dirSee Working outside of app context

txdev app delete

Deletes an existing app from the Developer Console. Execute with caution.

ParameterDescription
--id, --dirSee Working outside of app context

txdev app open

Opens an application in the Developer Console.

ParameterDescription
--id, --dirSee Working outside of app context

txdev app authorization

Configures app authorization. It's the command-line equivalent of adding the App Authorization block in Developer Console. You will be prompted to select scopes by the CLI.

Specifying auth details
Copied!
$ txdev app authorization add --type=server_side_app --redirectUri=https://myapp.com/
Authorization object added to app manifest
Copied!
"authorization": {
      "clientId": "5c4d731184619046c915549fb09c1561",
      "type": "server_side_app",
      "redirectUri": "https://myapp.com/",
      "scopes": [
        {
          "scope": "archives_read",
          "required": true
        }
      ]
    }
OptionParamDescription
addAdds authorization block
--typeOne of: javascript_app or server_side_app
--redirectUriComma-separated string. A list of addresses to be whitelisted by Text Accounts.
removeRemoves authorization block
--id , --dirSee Working outside of app context
App manifest location
openOpens the browser with App Authorization in Developer Console.
--id, --dirSee Working outside of app context

txdev app widgets

Configures LiveChat or HelpDesk widgets. It's the command-line equivalent of the Agent App Widgets or Ticket Widgets block in the Developer Console.

Specifying widget details
Copied!
$ txdev app widgets add --product=livechat --placement=plugin --url=https://myapp.com
Widgets object added to app manifest
Copied!
    "widgets": {
      "5elheVKFzJ": {
        "url": "https://myapp.com",
        "placement": "plugin",
        "initialState": "" // returned for all placements, but has effect only for Chat Details
      }
    }
OptionParamDescription
addAdds Agent App/Ticket Widgets block
--productOne of: livechat or helpdesk. Needs to be the same as app product.
--placementOne of: fullscreen, plugin (Chat Details), messagebox, settings, tickets (HelpDesk)
--urlWidget URL. Defined separetely for each widget placement.
--id, --dirSee Working outside of app context
removeRemoves all or selected widgets. The CLI will prompt you to select.
--id, --dirSee Working outside of app context
openOpens Developer Console in the browser
--id, --dirSee Working outside of app context

txdev app monetization

Configures app monetization. It's the command-line equivalent of the App Monetization block in the Developer Console. The CLI will guide you through the configuration.

Specifying widget details
Copied!
$ txdev app monetization add
Widgets object added to app manifest
Copied!
    "monetization": {
      "price": 100,
      "frequency": "monthly",
      "trialDays": 7,
      "charge": "organization"
    }
OptionParamDescription
addAdds App Monetization block
--id, --dirSee Working outside of app context
removeRemoves the block
--id, dirSee Working outside of app context
openOpens Developer Console in the browser
--id, --dirSee Working outside of app context

txdev app properties

Allows to remove LiveChat properties. It's the command-line equivalent of the Properties block in the Developer Console. The CLI allows you to edit app properties on published apps – execute with caution. The command doesn't support the add option -- this can be done in the Developer Console or via the Configuration API.

OptionParamDescription
removeRemoves the block
--id, dirSee Working outside of app context
openOpens Developer Console in the browser
--id, --dirSee Working outside of app context
Properties object added to app manifest
Copied!
    "properties": {
      "chat_note": {
        "type": "string",
        "description": "",
        "access": {
          "thread": {
            "agent": ["write"],
            "customer": ["read"]
          }
        }
      }
    }

txdev app variables

Fetches environment variables stored in the Developer Console.

OptionParamDescription
pullFetch environment variables stored in the Developer Console
--id, dirSee Working outside of app context
openOpens Developer Console in the browser
--id, --dirSee Working outside of app context

txdev app repository

Basic usage
Copied!
$ txdev app repository link
OptionParamDescription
linkLink an app repository
--providergithub
--typenew or existing
--nameRepository name
--fullName<organization/repository-name>. Specify to link an existing repository.
--branchBy default, the files are commited to main
--templatevite, nextjs, saas
--id, --dirSee Working outside of app context
unlinkUnlink an app repository
--id, dirSee Working outside of app context
--shouldDeleteBool. Specify true if you want to unlink and delete the repository.
pullFetch app repository to your local environment.
--id, dirSee Working outside of app context
openOpens the Developer Console in the browser.
--id, --dirSee Working outside of app context

txdev app deployment

Manages app deployment. It's the command-line equivalent of the Deployment block in the Developer Console. Support is provided for Netlify and Vercel.

Basic usage
Copied!
$ txdev app deployment link
OptionParamDescription
linkConfigure app deployment
--providerOne of: netlify, vercel
--type
--databaseName
--id, --dirSee Working outside of app context
unlinkFetch environment variables stored in the Developer Console
--shouldDeleteBool. Specify true if you want to unlink and delete the deployed site.
openOpens Developer Console in the browser
--id, --dirSee Working outside of app context

txdev app storage

Manages app storage. It's the command-line equivalent of the Storage block in the Developer Console.

Basic usage
Copied!
$ txdev app storage link
OptionParamDescription
linkConfigure storage for the app
--providerneon or planetscale
--typenew or existing
--databaseName
--id, --dirSee Working outside of app context
unlinkFetch environment variables stored in the Developer Console
--shouldDeleteBool. Specify true if you want to unlink and delete the repository.
openOpens Developer Console in the browser
--id, --dirSee Working outside of app context

auth module

txdev auth --help

Lists available commands in the auth module.

txdev auth --help
Copied!
$ txdev auth --help

Commands:
  txdev auth login   login to provider
  txdev auth logout  logout from provider

txdev auth login

Log in to Text or to an external provider. Select the provider with arrows or specifying it explicitly in as the --provider param.

ParameterOptions
--providerOne of: accounts (Text), github, netlify, neon, planetscale, vercel.
Basic usage
Copied!
$ txdev auth login

❯   Text (unauthorized)
    GitHub  (unauthorized)
    Netlify  (unauthorized)
    Neon  (unauthorized)
    PlanetScale  (unauthorized)
    Vercel  (unauthorized)
Specifying a provider
Copied!
$ txdev auth login --provider=github

txdev auth logout

Log out from Text or an external provider service. The command is analogous to the txdev auth login command.

Developer CLI on npm

To read more about the Developer SDK, visit its official page on npm.

...

Join the community
Get in direct contact with us through Discord.
Follow us
Follow our insightful tweets and interact with our content.
Contribute
See something that's wrong or unclear? Submit a pull request.
Contact us
Want to share feedback? Reach us at: developers@text.com