# Zendesk

## Integration Steps:

### Step 1: Create a conversation field &#x20;

Create a conversation field by going to [Zendesk admin center](https://zipy.zendesk.com/admin/home). Go to **Objects and rules** then go to fields.&#x20;

<figure><img src="https://3440602746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcCYilc27NCELgnKQNPVF%2Fuploads%2FoBCwEXZNYncR3JtxshuV%2Fimage.png?alt=media&#x26;token=9966e76d-98aa-41c1-9d8d-3563946538c2" alt=""><figcaption></figcaption></figure>

Click on Add Field and select the type as **Text**.

<figure><img src="https://3440602746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcCYilc27NCELgnKQNPVF%2Fuploads%2FbKlfGTBrNLhqg2k8doCU%2Fimage.png?alt=media&#x26;token=576f9151-461d-434f-b7ff-1786372be91a" alt=""><figcaption></figcaption></figure>

Set the permissions to **Customers can edit .**

<figure><img src="https://3440602746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcCYilc27NCELgnKQNPVF%2Fuploads%2FCRWAbftRtGmyw72YYjdC%2Fimage.png?alt=media&#x26;token=8b13709d-fb60-4425-b1a5-37b734c58424" alt=""><figcaption></figcaption></figure>

Save the field and copy its field id, this will be needed in later steps.&#x20;

### Step 2: Install Zendesk chat widget

Go to channels in Zendesk admin center. Go to Channels section. Then go to messaging under messaging and social section. Create a channel if not created. Scroll to the Installation section and copy the code. Just paste this code snippet in before the closing `</body>` tag.

### Step 3: Code to get Zipy session Url in Zendesk conversation

```javascript
<script>
  setTimeout(() => {
    const zipySessionUrl = window.zipy.getCurrentSessionURL();
    zE("messenger:set", "conversationFields", [
        { id: <FIELD_ID>, value: zipySessionUrl }
    ]);
  }, 1500);
</script>

```

*Note : Replace \<FIELD\_ID> by yours.*

*Note : setTimeout is used here to get zipy sesison url after zipy is initialized.*

Refer this documentation for more info on Zendesk messenger events : <https://developer.zendesk.com/api-reference/widget-messaging/web/core/#set-conversation-fields>&#x20;

### Step 4: Zipy Session URL in Zendesk&#x20;

After the above steps are completed whenever a user visits your application and starts conversation you can see the users' Zipy session url in Zendesk.&#x20;

When viewing a specific conversation in Zendesk, navigate to the left panel. Here, you should find the field which you have created in previous steps to store Zipy session url along with its corresponding value, which represents the Zipy session URL.

<figure><img src="https://3440602746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcCYilc27NCELgnKQNPVF%2Fuploads%2FEc1GFCPgIskERNkPisdv%2Fimage.png?alt=media&#x26;token=0c84575a-8d6f-4a72-968a-89d8bb285447" alt=""><figcaption></figcaption></figure>

**Important Note:** If you are using **Web Widget (Classic)** from Zendesk, as it does not allows you to update conversation field, you can send Zipy session url in pages viewed section using the script given below.

```javascript
<script type="text/javascript">
  // Note : Insert this script after the Zendesk Installation script
  // This script will add the Zipy session URL to the Zendesk conversation's "pages viewed" section
  setTimeout(() => {
    const zipySessionUrl = window.zipy.getCurrentSessionURL();
    
    zE('webWidget', 'updatePath', {
      url: zipySessionUrl,
      title: "Zipy session"
    });
  },1500);
</script>
```
