title: Vonage Api Call Function
body: <p>Hey I got my code to receive calls but for some reason when I run the script it doesn’t place an out going call. I am not getting no error message or anything it just simply won’t call,But I set up everything right am I missing a trigger or something? Could someone please point me in the right direction I’ve been trying to build this api for about 4 Months.</p>
  <pre><code>require('dotenv').config();
  const Vonage = require('@vonage/server-sdk');
  const express = require('express');
  const morgan = require('morgan');
  
  const app = express();
  const vonage = new Vonage({
    apiKey: process.env.VONAGE_API_KEY,
    apiSecret: process.env.VONAGE_API_SECRET,
    applicationId: process.env.VONAGE_APPLICATION_ID,
    privateKey: process.env.VONAGE_PRIVATE_KEY_PATH
  });
  
  app.use(morgan('tiny'));
  app.use(express.json());
  
  app.get('/call', (req, res) =&gt; {
    vonage.calls.create({
      to: [{
        type: 'phone',
        number: process.env.TO_NUMBER
      }],
      from: {
        type: 'phone',
        number: process.env.VONAGE_NUMBER,
      },
      ncco: [{
        &quot;action&quot;: &quot;talk&quot;,
        &quot;text&quot;: &quot;This is a text to speech call from Vonage&quot;
      }]
    }, (error, response) =&gt; {
      if (error) console.error(error)
      if (response) console.log(response)
    });
    res.json('ok');
  });
  
  app.post('/event', (req, res) =&gt; {
    console.log(req.body);
    res.status(200).send('');
  });
  
  app.post('/answer', (req, res) =&gt; {
    const number = req.body.from.split('').join(' ');
    const ncco = [
      {
        action: 'talk',
        text: 'Thank you for calling from ' + number,
        language: 'en-IN',
        style: '4'
      },
      {
        action: 'stream',
        streamUrl: [
          'https://www.albinoblacksheep.com/audio/mp3/RickRollMarioPaint.mp3'
        ]
      }
    ];
    res.json(ncco);
  });
  
  
  app.listen(process.env.PORT, () =&gt; console.log(Running on port ${process.env.PORT}));
  </code></pre>