You can use the built-in method of the app library named app.raiseTicket().
This takes an object
issue: "Issue Description",
phone: "Phone Number",
name: "User Name",
email: 'Email ID' ( optional, but recommended to add )
priority: 'MEDIUM' ( can be LOW or HIGH as well )
category: 'category-name' ( optional, in case the queries need to be routed to specific groups of agents )
This returns a promise which has an object. If this object contains a key assignedTo, then the ticket has been assigned. If the status ( another key inside this object ) of the ticket is QUEUED, then the ticket is in the agent queue and will be assigned as soon previous tickets are closed. If ticketData is not returned by the method, then no agents are online. Handle this appropriately in your code.