Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voicemail to Email Enhancement #27

Open
dillonator opened this issue Jan 27, 2021 · 0 comments
Open

Voicemail to Email Enhancement #27

dillonator opened this issue Jan 27, 2021 · 0 comments

Comments

@dillonator
Copy link

Not really an issue but just an idea/enhancement. We have been using VictorOps for on-call for a few months and only a select few IT admins have access to Twilio. Callers shouldn't go to voicemail often but if and when it does, the transcription isn't great (global office, callers from multiple countries, accents involved). So, our on-call folks want access to the voicemail so they can listen to what the issue is. I tried going through support but didn't get very far with VictorOps or Twilio (not my first choice for on-call products). One suggested this: https://www.twilio.com/blog/forward-voicemail-recordings-to-email

So, I've tried to add this code (I'm not a programmer/scripter by any means and I certainly don't know JavaScript). It seems to work but sends 2 emails. Do I have the right idea here? Should this be broken out into it's own function?

//Continuation of leaveAMessage function. Email code starts at Attempt to email voicemail comment
      twiml.record(
        {
          transcribe: true,
          transcribeCallback: generateCallbackURI(
            context,
            {
              callerId,
              detailedLog,
              goToVM,
              runFunction: 'postToVictorOps',
              teamsArray
            }
          ),
          timeout: 10,
          action: generateCallbackURI(
            context,
            {
              callerId,
              detailedLog,
              runFunction: 'leaveAMessage',
              sayGoodbye: true,
              teamsArray
            }
          )
        }
      );
    }
    //Attempt to email voicemail
    //Initialize SendGrid Mail Client
    // put this above?
    const sgMail = require('@sendgrid/mail');

    // Define Handler function required for all Twilio Functions (possibly not required since already within function)
    //exports.handler = function(context, event, callback) {

    // Build SG mail request
    sgMail.setApiKey(context.SENDGRID_API_SECRET);
        // Define message params
        const msg = {
          to: context.TO_EMAIL_ADDRESS,
          from: context.FROM_EMAIL_ADDRESS,
          text: `New VictorOps Voicemail from: ${event.From}\n Transcription is: ${event.TranscriptionText}\n Recording URL is: ${event.RecordingUrl}`,
          subject: `New VictorOps Voicemail from: ${event.From}`,
        };
        // Send message
        sgMail.send(msg)
        .then(response => {
            console.log("Recording Emailed.")
            callback();
        })
        .catch(err => {
            console.log("Error, Recording not emailed.")
            callback(err);
        });

  resolve(twiml);
  });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant