Skip to content

Commit

Permalink
feat: webhook support in macros
Browse files Browse the repository at this point in the history
  • Loading branch information
nestordavalos authored and milesibastos committed Aug 21, 2024
1 parent 59fd3d9 commit 053c328
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export const MACRO_ACTION_TYPES = [
label: 'Resolve conversation',
inputType: null,
},
{
key: 'send_webhook_event',
label: 'Send Webhook Event',
inputType: 'url',
},
{
key: 'send_attachment',
label: 'Send Attachment',
Expand Down
2 changes: 1 addition & 1 deletion app/models/macro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Macro < ApplicationRecord

validate :json_actions_format

ACTIONS_ATTRS = %w[send_message add_label assign_team assign_agent mute_conversation change_status remove_label remove_assigned_team
ACTIONS_ATTRS = %w[send_message add_label assign_team assign_agent mute_conversation change_status remove_label remove_assigned_team send_webhook_event
resolve_conversation snooze_conversation change_priority send_email_transcript send_attachment add_private_note].freeze

def set_visibility(user, params)
Expand Down
5 changes: 5 additions & 0 deletions app/services/macros/execution_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def perform

private

def send_webhook_event(webhook_url)
payload = @conversation.webhook_data.merge(event: "macro_event.#{@macro.name}")
WebhookJob.perform_later(webhook_url[0], payload)
end

def assign_agent(agent_ids)
agent_ids = agent_ids.map { |id| id == 'self' ? @user.id : id }
super(agent_ids)
Expand Down

0 comments on commit 053c328

Please sign in to comment.