# Add Tag To Contact with Intercom API

## Pipedream makes it easy to connect APIs for Intercom and 3,000+ other apps remarkably fast.

**Trigger workflow on**

HTTP requests, schedules and app events

### Next, do this

Add Tag To Contact with the Intercom API

### Trusted by 1,000,000+ developers from startups to Fortune 500 companies

## Developers ♥ Pipedream

### Getting Started

Create a workflow to Add Tag To Contact with the Intercom API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

1. **Configure** the Add Tag To Contact action
2. Connect your `Intercom` account
3. Select a `Contact ID`
4. Select a `Tag ID`
5. **Select a trigger** to run your workflow on HTTP requests, schedules or app events
6. **Deploy** the workflow
7. **Send a test event** to validate your setup
8. **Turn on** the trigger

### Details

This is a pre-built, source-available component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

**Add Tag To Contact on Intercom**  
Description: Adds a specific tag to a contact in Intercom. [See the documentation](https://developers.intercom.com/docs/references/rest-api/api.intercom.io/contacts/attachtagtocontact).

#### Code

```javascript
import intercom from "../../intercom.app.mjs";

export default {
  key: "intercom-add-tag-to-contact",
  name: "Add Tag To Contact",
  description: "Adds a specific tag to a contact in Intercom. [See the documentation](https://developers.intercom.com/docs/references/rest-api/api.intercom.io/contacts/attachtagtocontact).",
  version: "0.0.3",
  annotations: {
    destructiveHint: false,
    openWorldHint: true,
    readOnlyHint: false,
  },
  type: "action",
  props: {
    intercom,
    contactId: {
      type: "string",
      label: "Contact ID",
      description: "The unique identifier for the contact which is given by Intercom. Eg. `63a07ddf05a32042dffac965`.",
      propDefinition: [
        intercom,
        "userIds",
        () => ({
          data: {
            query: {
              operator: "OR",
              value: [
                {
                  field: "role",
                  operator: "=",
                  value: "user",
                },
                {
                  field: "role",
                  operator: "=",
                  value: "lead",
                },
              ],
            },
          },
        }),
      ],
    },
    tagId: {
      propDefinition: [
        intercom,
        "tagId",
      ],
    },
  },
  methods: {
    addTagToContact({
      contactId, ...args
    } = {}) {
      return this.intercom.makeRequest({
        method: "POST",
        endpoint: `contacts/${contactId}/tags`,
        ...args,
      });
    },
  },
  async run({ $ }) {
    const {
      addTagToContact,
      contactId,
      tagId,
    } = this;

const response = await addTagToContact({
      $,
      contactId,
      data: {
        id: tagId,
      },
    });

$.export("$summary", `Successfully added tag to contact with ID \\`${response.id}\\`.`);
    return response;
  },
};
```

#### Configuration

| Label      | Prop          | Type   | Description                                                            |
|------------|---------------|--------|------------------------------------------------------------------------|
| Intercom   | `intercom`    | `app` | This component uses the Intercom app.                                 |
| Contact ID | `contactId`   | `string` | Select a value from the drop down menu.                               |
| Tag ID     | `tagId`       | `string` | Select a value from the drop down menu.                               |

#### Authentication

Intercom uses OAuth authentication. When you connect your Intercom account, Pipedream will open a popup window where you can sign into Intercom and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Intercom API.
