forked from Ilhasoft/goflow
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package actions | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/nyaruka/goflow/assets" | ||
"github.com/nyaruka/goflow/flows" | ||
"github.com/nyaruka/goflow/flows/events" | ||
|
@@ -16,21 +19,21 @@ const TypeOpenTicket string = "open_ticket" | |
|
||
// OpenTicketAction is used to open a ticket for the contact. | ||
// | ||
// { | ||
// "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", | ||
// "type": "open_ticket", | ||
// "ticketer": { | ||
// "uuid": "19dc6346-9623-4fe4-be80-538d493ecdf5", | ||
// "name": "Support Tickets" | ||
// }, | ||
// "topic": { | ||
// "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
// "name": "Weather" | ||
// }, | ||
// "body": "@input", | ||
// "assignee": {"email": "[email protected]", "name": "Bob McTickets"}, | ||
// "result_name": "Help Ticket" | ||
// } | ||
// { | ||
// "uuid": "8eebd020-1af5-431c-b943-aa670fc74da9", | ||
// "type": "open_ticket", | ||
// "ticketer": { | ||
// "uuid": "19dc6346-9623-4fe4-be80-538d493ecdf5", | ||
// "name": "Support Tickets" | ||
// }, | ||
// "topic": { | ||
// "uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
// "name": "Weather" | ||
// }, | ||
// "body": "@input", | ||
// "assignee": {"email": "[email protected]", "name": "Bob McTickets"}, | ||
// "result_name": "Help Ticket" | ||
// } | ||
// | ||
// @action open_ticket | ||
type OpenTicketAction struct { | ||
|
@@ -82,6 +85,10 @@ func (a *OpenTicketAction) Execute(run flows.FlowRun, step flows.Step, logModifi | |
if ticket != nil { | ||
a.saveResult(run, step, a.ResultName, string(ticket.UUID()), CategorySuccess, "", "", nil, logEvent) | ||
} else { | ||
fmt.Println("empty ticket") | ||
if strings.HasPrefix(evaluatedBody, `{"id":`) { | ||
a.saveResult(run, step, a.ResultName, "", CategorySuccess, "", "", nil, logEvent) | ||
} | ||
a.saveResult(run, step, a.ResultName, "", CategoryFailure, "", "", nil, logEvent) | ||
} | ||
|
||
|