/
Message Sent by Agent Trigger

Message Sent by Agent Trigger

The Message Sent by Agent trigger in UChat is used to capture messages sent by a human agent during a conversation and trigger automated workflows based on those messages. This documentation provides a step-by-step guide on how to set up and use this trigger, including custom fields and an example flow that sends an email notification.

Step 1: Creating the Trigger

  1. Navigate to the Triggers Section:

    • In UChat, go to Triggers in the left-side menu.

    • Click on Internal Functions.

    • Click on the New Trigger button (top-right corner).

  2. Select the Event:

    • In the list of available events, select Message Sent by Agent.

  1. Activate the Trigger:

    • Enable the trigger by switching the toggle to Activated.

    • Name the trigger appropriately (e.g., Agent Message Trigger).

  2. Save Custom Fields:

    • Assign custom fields to store key message details:

      • Agent_ID → Stores the unique ID of the agent who sent the message.

      • Time → Stores the timestamp when the message was sent.

      • Agent_Message → Stores the content of the message.

 

  1. Save and Confirm:

    • Click Save to confirm the trigger setup.

    • The trigger will now appear in the list of active triggers.

Step 2: Creating an Automated Flow

Once the trigger is set up, we can create a flow that uses the agent message data.

  1. Open the Flow Builder:

    • Create a new workflow or edit an existing one.

    • Add an action node that will process the trigger data and send an email notification for example (you can create other actions if you prefer).

 

  1. Add an Email Notification Action:

    • Select the Send Email Notification action.

  • Configure the email settings:

    • Email Profile: Choose the SMTP profile.

    • To Email: Enter the recipient email.

    • Subject: Set a relevant subject like Agent Message.

    • Message: Use the Agent_Message field to include the agent's message content in the email body.

  1. Save and Publish:

    • Click Save to store the settings.

    • Publish the flow to activate it.

Step 3: Testing the Trigger

  1. Send a Message as an Agent:

    • Open a conversation and send a message as an agent.

    • The trigger should capture the message and store the details in the assigned fields.

  2. Check the Email Notification:

    • Verify that the configured email is received with the correct message details.

Example JSON Output

The stored message data will be structured as follows:

{

  "type": "text",

  "agent_id": 51263,

  "time": "2025-01-30T01:43:22Z",

  "text": "John Doe:\nMessage by Vitor",

  "url": ""

}

This JSON object contains:

  • type: The type of message (e.g., text, image, etc.).

  • agent_id: The unique ID of the agent.

  • time: The timestamp of the message.

  • text: The content of the message.

  • url: A placeholder for media attachments (if any).

Conclusion

The Message Sent by Agent trigger is useful for automating responses and actions based on agent interactions. By following the steps in this guide, you can efficiently capture agent messages and integrate them into workflows, such as email notifications or other automated processes.