Thirk
Thirk

Reputation: 593

Creating an Asterisk "application" to send GET requests from an endpoint via Phone Prompt

To start off, I'd like to state that this is my first dive into Asterisk related applications, and that I'm mostly a web developer.

My workplace uses an MSP that installed Asterisk/FreePBX to manage our phone systems. The GUI is pretty intuitive and after reading and getting a bit lost I figured I'd come here and see how to go about setting this up.

I was tasked with building a simple application to reset user passwords through both a web interface (completed) and a phone interface - by dialing a number, dialing their ID card #, and then having their password reset. I'm a Systems Administrator and have access to all necessary applications, servers, etc. I can pick things up fairly easy and I was told I'd have enough time to figure this out and get it done.

This is what I need in terms of pseudocode when the user calls a specific extension:

recording('pwResetCardID'); // Play a "Please enter your ID # to reset PW" greeting. 

function getCardID() {
    cardID = input(); // Input 4-5 digits using the dialpad and save it to a var.
    verify = get('http://some.site/endpoint/cardid/'.$cardid); // Send a GET request.
    if verify { // If we got a successful response (200)
        recording('pwChanged'); // Tell the user their password has changed
    } else { // 
        recording('errorCardID'); // Otherwise tell them to try again
        getCardID(); // Recur the function.
    }
}

getCardID();

If the cardID is valid, their PW is changed on the other end of my node.js application, and I simply need the GET request to be sent out and the user notified of the success (or failure)

Upvotes: 0

Views: 969

Answers (1)

arheops
arheops

Reputation: 15259

You can start from doc describing asterisk dialplan

Probably need use func_CURL, Read application, Playbavk and Goto

You need put new dialplan in extensions_custom.conf and setup use it via custom apps module

Upvotes: 1

Related Questions