Working Locally

The Code Hub can be used entirely from the command line using the CLI if you'd rather use your own tools to work locally.

To deploy an application directly from the browser without local tooling, see our guide on working in the cloud.

CLI Installation

Code Hub can be used entirely from the command-line; vcr is the command-line interface that is required for managing and deploying your applications from the terminal.

pwsh -Command "iwr https://raw.githubusercontent.com/Vonage/cloud-runtime-cli/main/script/install.ps1 -useb | iex"

Configure the CLI

Configure your account using this command:

vcr configure 

The command will ask for your a default region as well as your Vonage API key and secret which you can get from the from the API Dashboard.

CLI Configuration File

vcr configure writes your credentials and preferences to ~/.vcr-cli. You can also edit this file directly. The file uses INI format:

[default]
graphql_endpoint = https://api-eu.vonage.com/v1/vcr/euw1/api/graphql/v1/graphql
default_region = aws.euw1

[credentials]
apikey = YOUR_API_KEY
apisecret = YOUR_API_SECRET

The graphql_endpoint for each region is:

Region Endpoint
EU West (aws.euw1) https://api-eu.vonage.com/v1/vcr/euw1/api/graphql/v1/graphql
US East (aws.use1) https://api-us.vonage.com/v1/vcr/use1/api/graphql/v1/graphql
AP Southeast (aws.apse1) https://api-ap.vonage.com/v1/vcr/apse1/api/graphql/v1/graphql
AP Southeast Sydney (aws.apse2) https://api-ap.vonage.com/v1/vcr/apse2/api/graphql/v1/graphql

Updating the CLI

To update the CLI run:

vcr upgrade

This will print out the current version of the CLI you have installed. If there is a newer version available, you will be prompted to install it.

NOTE: You may need to run the command using sudo to give the Cloud Runtime CLI permissions to move the new CLI version into the installation folder. You can also perform the move yourself.

Using the CLI

To initialize a project, run the following command to start inputting your details:

vcr init

Running the command will prompt you for the following information:

  • Project name: a name for your project.
  • Instance Name: Enter a name for the instance that will be created. You can have multiple instances for a single project, so this should be memorable.
  • Runtime: Select the runtime you want to use when the code is executed.
  • Region: Select the region you want your instance to run in.
  • Application ID for Instance: In order to use the Vonage APIs, an Application is required. Select the Application ID for the application you wish to use; if you haven't created one yet, you can skip this step and enter the ID later. To create an application, go to the Applications page on the Vonage dashboard or run vcr app create. When you deploy your instance, Cloud Runtime will automatically configure the webhooks on your application for you.
  • Application ID for Debug: You can supply a separate Application ID to be used only for debugging, meaning that your deployed instance and corresponding Application and webhooks will not be affected by local debugging.
  • Template: Choose a template from the list to view an existing project. A full list of templates can be found in the Code Hub

Once you have entered all of the necessary information a vcr.yml config file will be created, where you can add anything you skipped, or edit any of the details you just provided. If you have selected a template, the files required for running that application will also be downloaded. You can now open those files in your local setup to begin viewing and editing the project.

Next Steps

When you are working on your project, you may find the following resources useful:

  • Debugging: Debug your code locally as if it was deployed on the platform.
  • Deploying: When your project is ready, quickly create a running instance on the platform by deploying.

Managing Applications

You can manage Vonage Applications from the CLI using the vcr app commands.

To create a new application:

vcr app create --voice --messages

To regenerate the private key and public key for an existing application:

vcr app generate-keys --app-id YOUR_APPLICATION_ID

This replaces the application's existing key pair. The new private key will be downloaded and you will need to update any references to it in your project or secrets.