# Create and Dispatch Message — iContact

> Creates and dispatches a new message using custom HTML. See the documentation

- Key: `icontact-create-message`
- Type: Action (Write)
- Version: 0.0.2
- App: iContact (`icontact`) — https://pipedream.com/apps/icontact.md
- This page (HTML): https://pipedream.com/apps/icontact/actions/create-message
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/icontact/actions/create-message/create-message.mjs

## Description

Creates and dispatches a new message using custom HTML. [See the documentation](https://help.icontact.com/customers/s/article/Messages-iContact-API?r=153&ui-knowledge-components-aura-actions.KnowledgeArticleVersionCreateDraftFromOnlineAction.createDraftFromOnlineArticle=1)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `campaignId` | `string` | Yes | The sender property from which the message will pull its sending information. Options are loaded from the connected account. |
| `messageType` | `string` | Yes | The kind of message being added. |
| `subject` | `string` | Yes | The subject line of the email. |
| `htmlBody` | `string` | No | Contains the HTML version of the email message body. |
| `textBody` | `string` | No | Contains the text version of the email message body. |
| `messageName` | `string` | No | The reference name of the message. This is used for organizational purposes and will not be seen by your contacts. |
| `previewText` | `string` | No | Indicates the preview text that some email systems display before opening the email. |
| `replyToCampaignId` | `string` | No | Indicates the sender property where you want reply emails to be sent to. Options are loaded from the connected account. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "icontact",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "icontact-create-message",
  arguments: {
    campaignId: "Campaign ID",
    messageType: "Message Type",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "icontact-create-message",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    icontact: { authProvisionId: "apn_xxxxxxx" },
    campaignId: "Campaign ID",
    messageType: "Message Type",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "icontact-create-message",
    "configured_props": {
      "icontact": { "authProvisionId": "apn_xxxxxxx" },
      "campaignId": "Campaign ID",
      "messageType": "Message Type"
    }
  }'
```

---

- App: https://pipedream.com/apps/icontact.md · All apps: https://pipedream.com/apps
