Question

How can I retrieve the URL of a Web Widget conversation for use in AI Agents - Advanced?

Answer

Use messaging metadata to store the URL in a custom ticket field.

The workflow includes these steps:

  • Step 1: Create the custom text ticket field
  • Step 2: Create the AI agent action
  • Step 3: Add the Web Widget JavaScript

Step 1: Create the text ticket field

  1. In Admin Center, click Objects and rules in the sidebar, then select Tickets > Fields
  2. Click Add field, and then select Text
  3. Under Display name, add URL
  4. In Permissions, select Customers can edit
  5. Create a custom text ticket field and name it URL. Under the Permissions section, select Customers can edit.
  6. Click Save
  7. Optionally, add the created text field to all ticket forms your agents use for messaging with customers
  8. Access your ticket fields to copy the URL ticket field ID
    Fields page highlight the field ID

Step 2: Create the AI agent action

  1. Select your messaging AI Agent. Open Settings > CRM Integration to verify that Sunshine Conversations is authorized. If not, click Add CRM integration and select Messaging.
  2. Create an action with these settings:
    • Name | Get URL
    • Targets | Sunshine Conversations
    • Task | Get Conversation
    • Field to retrieve | Metadata
    • Key | Paste the value zen:ticket_field:<fieldId> and replace the <fieldId> with the ticket field ID from step 1
  3. Set the action to run in your workflow. To run it at the start of every conversation, go to Settings > AI Agent Settings > Events and Actions. Click Add action, select Conversation started, then select the action from the previous step.

Step 3: Add the Web Widget JavaScript

  1. Add this code to the website or help center where you embed the Web Widget. Replace the <fieldId> value with the field ID from step 1:

    <script>
    zE('messenger:set', 'conversationFields', [{ id: '<fieldId>', value: window.location.href }]);
    </script>

    If you add this JavaScript to a help center, include it in the script.js template. For more information, see the article: Customizing the CSS or JavaScript

  2. The system now records the URL in the messaging metadata as part of your AI Agents - Advanced workflows
Disclaimer: This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Zendesk also can't provide support for third-party technologies such as JavaScript, jQuery, or CSS. Post any issues you have in the comments section or try searching for a solution online.
Powered by Zendesk