Skip to content

Commit

Permalink
Add event logs for send_msg_catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
Robi9 committed Oct 30, 2023
1 parent 9a2f4ff commit 3a86973
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions flows/actions/send_msg_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ func (a *SendMsgCatalogAction) Execute(run flows.FlowRun, step flows.Step, logMo

destinations := run.Contact().ResolveDestinations(a.AllURNs)

var status flows.CallStatus

// create a new message for each URN+channel destination
for _, dest := range destinations {
var channelRef *assets.ChannelReference
Expand All @@ -131,9 +133,24 @@ func (a *SendMsgCatalogAction) Execute(run flows.FlowRun, step flows.Step, logMo
params := assets.NewMsgCatalogParam(evaluatedHeader, evaluatedBody, evaluatedFooter, products, a.ProductViewSettings.Action, string(a.Topic), a.AutomaticSearch, evaluatedSearch, envs.NilLanguage, uuids.UUID(dest.Channel.UUID()))
c, err := a.call(run, step, params, mc, logEvent)
if err != nil {

status = flows.CallStatusResponseError
callWeniGPT := &flows.WebhookCall{Trace: c.TraceWeniGPT}
logEvent(events.NewWebhookCalled(callWeniGPT, status, ""))
callSentenx := &flows.WebhookCall{Trace: c.TraceSentenx}
logEvent(events.NewWebhookCalled(callSentenx, status, ""))

a.saveResult(run, step, a.ResultName, fmt.Sprintf("%s", err), CategoryFailure, "", "", nil, logEvent)

return nil
}

status = flows.CallStatusSuccess
callWeniGPT := &flows.WebhookCall{Trace: c.TraceWeniGPT}
logEvent(events.NewWebhookCalled(callWeniGPT, status, ""))
callSentenx := &flows.WebhookCall{Trace: c.TraceSentenx}
logEvent(events.NewWebhookCalled(callSentenx, status, ""))

a.saveResult(run, step, a.ResultName, string(c.ResponseJSON), CategorySuccess, "", "", c.ResponseJSON, logEvent)

products = c.ProductRetailerIDS
Expand Down
2 changes: 2 additions & 0 deletions flows/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ type ExternalServiceCall struct {
type MsgCatalogCall struct {
ResponseJSON []byte
ProductRetailerIDS []string
TraceWeniGPT *httpx.Trace
TraceSentenx *httpx.Trace
}

// ClassificationService provides NLU functionality to the engine
Expand Down

0 comments on commit 3a86973

Please sign in to comment.