While creating a ticket via the API, the ticket is successfully created. However, the phone number extracted from WhatsApp does not get passed to the system. Additionally, the users are new and do not exist in the system. My goal is to create a user with their phone number at the same time as creating the ticket. Below is my code:
javascript
Copiar
Editar
const osTicketAPI = require('osticket-nodejs-api-wrapper');
/**
* Creates a ticket in OSTicket using the API
* @"Param"#229587 {string} nameUser - The name of the customer
* @"Param"#229587 {string} mailUser - The email of the customer
* @"Param"#229587 {string} subjectUser - The subject of the ticket
* @"Param"#229587 {string} messageUser - The detailed message of the ticket
* @"Param"#229587 {string} topicIdUser - The topic ID or name in OSTicket
* @"Param"#229587 {number} usernumber - The customer's phone number
*/
function createTicket(nameUser, mailUser, subjectUser, messageUser, topicIdUser, usernumber) {
// Ticket data
const formData = {
name: nameUser,
email: mailUser,
subject: subjectUser,
message: messageUser,
topicId: topicIdUser,
phone: usernumber,
};
// API configuration
osTicketAPI(
{
API_KEY: 'myapikey', // API key
INSTALL_URL_PATH: 'http://domain/osticket/upload', // OSTicket URL
ALERT: true, // Send alerts
AUTO_RESPOND: true, // Enable auto-responses
},
formData,
function (err, osTicketId) {
if (!err) {
console.log('Your osTicket Support Ticket ID #', osTicketId);
} else {
console.error('Error creating support ticket!', err);
}
}
);
}
// Test function to create a ticket
createTicket(
'Customer Name', // Customer name
'email@noemail.com', // Customer email
'API Test', // Subject
'Testing WhatsApp API', // Message
1, // Topic ID
1234556 // Phone number
);
thanks 😉