jurgob / vapi_hello_world

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vapi_hello_world

what is this app?

this is an hello world for the nexmo voice API https://developer.nexmo.com/voice/voice-api/overview.

prerequisites

To make this app running, you need

once you have the necessary data ,you need to create a .env file in the project root directory with the following variables:

how to install the dependencies

install nvm (https://github.com/nvm-sh/nvm) from the root directory of this project run: nvm install (only the first time)

nvm use

npm install

first run / create the .env config file.

now you need to configure the .env file. you can run:

npm run first_config <API_KEY> <API_SECRET> <NEXMO_LVN> <APP_NAME>

you can find those values here:

npm run first_config a508b666 6ea37679e0d6a666 447520660591 vapi_ivr_hello_world

what is this doing? this command is creating a nexmo application for you and saving the needed information in a .env file. You should now see a .env file created in your project directory with the following content:

MY_NEXMO_APP_API_KEY=[API_KEY]
MY_NEXMO_APP_API_SECRET=[API_SECRET]
MY_NEXMO_APP_PHONE_NUMBER=[NEXMO_VN]
MY_NEXMO_APP_APPLICATION_NAME=[APP_NAME]
MY_NEXMO_APP_APPLICATION_ID=[APPLICATION_ID]
MY_NEXMO_APP_PRIVATE_KEY=[PRIVATE_KEY]

how to run it

once everything is configured, you can run the following command:

npm start

note: this is a dev app, so every time

how to read the logs

This project use a logging library called bunyan whitch is producing json logs. You may struggle in reading row logs. The logs are printed in the starndard output but also written in the vapi_hello_world.log file. so my suggestion is:

  1. install the bunyan cli: npm install -g bunyan (you must to this just once)
  2. run the app
  3. open another terminal on the same directory
  4. run tail -f vapi_hello_world.log | bunyan. you will now see a formatted log.

p.s. bunyan is producing standard json, so you can also use standard unix tools like jq to format the logs: tail -f vapi_hello_world.log | jq

how should I use it?

Once your server is running, just call from your phone the LVN number you bougth from nexmo

the first exercise you should do:

Take the current app and ask the question: "What do you prefer, fish and chips or potato?" "If you prefer fish and chips press 1, of you prefer potatos is 2"

if the user press one it should hear: "you have selected fish and chips, you should drink it with beer"

if the user press two it should hear: "glad you selected potatos, have a coke with them"

About


Languages

Language:JavaScript 100.0%