Created
January 29, 2015 07:37
-
-
Save lesterjude/09d282ffb8c5494d7338 to your computer and use it in GitHub Desktop.
Uservoice Create Ticket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var credentials = { | |
"key": "{$uservoice_key}", | |
"secret": "{$uservoice_secret}", | |
"base_url": "{$uservoice_base_url}", | |
"session_id": localSession.beatsession_guid | |
} | |
var dashboard_url = "https://dashboard.drumbi.com/v1/notification/"; | |
function createTicket(sessionData) { | |
var number = sessionData.caller_number.replace(/[^0-9]/g,""); | |
var email = sessionData.caller_email || number + "@drumbi.com"; | |
var body = 'Incoming Call From ' + sessionData.caller_number + ' \n' | |
+ 'Subject: ' + sessionData.subject + ' > New \n' | |
+ 'Name: No Name (Direct Call) \n' | |
+ 'Email:' + email + '\n' | |
+ 'Platform: ' + sessionData.platform + ' \n' | |
+ 'Session ID: ' + localSession.beatsession_guid + '\n' | |
+ 'Dashbord: ' + dashboard_url + localSession.beatsession_guid; | |
//get email | |
uservoice.createTicket({ | |
ticket: { | |
subject: "Phone Call > " + sessionData.subject + ' > New', | |
status: 'open', | |
priority: 'normal', | |
comment: { | |
body: body, | |
public: false | |
}, | |
via_id: 44 | |
}, | |
caller: { | |
name: "No Name (Direct Call)", | |
email: email, | |
number: sessionData.caller_number | |
}, | |
credentials: credentials | |
}, function(err, result) { | |
var ticketId = result.data.ticket.ticket.split("/"); | |
ticketId = ticketId[ticketId.length-1] | |
drumbi.set({ | |
notification_url: result.data.ticket.ticket, | |
uservoice: result.data.ticket.ticket, | |
ticket_id: ticketId, | |
topic: sessionData.subject | |
}, function(err, result) { | |
drumbi.connectCaller(); | |
}) | |
}); | |
} | |
drumbi.set('set_attachment', "true", function() {}); | |
drumbi.getAllVariables(function(err, sessionData) { | |
var json = { | |
caller_email: '', | |
caller_name: '', | |
caller_number: sessionData.callback_number, | |
subject: sessionData.topic, | |
credentials: credentials, | |
session_id: localSession.beatsession_guid, | |
platform: sessionData.platform | |
}; | |
drumbi.set('session_info', JSON.stringify(json), function() { | |
createTicket(json); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment