# Send Survey — AskNicely

> Trigger a survey to a contact. See the documentation

- Key: `asknicely-send-survey`
- Type: Action (Write)
- Version: 0.0.3
- App: AskNicely (`asknicely`) — https://pipedream.com/apps/asknicely.md
- This page (HTML): https://pipedream.com/apps/asknicely/actions/send-survey
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/asknicely/actions/send-survey/send-survey.mjs

## Description

Trigger a survey to a contact. [See the documentation](https://demo.asknice.ly/help/apidocs/survey)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `email` | `string` | Yes | The email of the contact. |
| `name` | `string` | No | The name of the contact. |
| `triggeremail` | `boolean` | No | If set to true, the API will always send a survey, we recommend to only use this parameter for testing the API to see the survey emails being sent. Remove this entirely when in production, as including this parameter will override all contact rules and send a survey for each API call. Setting false won't stop it from sending surveys. |
| `delayminutes` | `integer` | No | If you want to trigger a survey to have a delay, use delayminutes. 10 = 10 minute delay. 7 day delay would be 60247 = 10800, there is no limit to how minutes or days you can delay. This value ignored for sms, surveys are always sent immediately. |
| `segment` | `string` | No | Set a customers segments. |
| `customFields` | `object` | No | Add extra argments to send through extra custom data to help identify/filter/leaderboard customers. Multiple arguments can be sent with each request. |
| `thendeactivate` | `boolean` | No | After a survey has been sent, de-activate this customer so they are not eligible for NPS surveys sent via the Daily Scheduler on the Send page. If you wish to de-activate a customer regardless of if a survey is sent or not, please use the remove contact API. Very handy if you are using both the Daily Scheduler and API calls. |

## 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": "asknicely",
      },
    },
  },
)

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: "asknicely-send-survey",
  arguments: {
    email: "Email",
    name: "Name",
  },
})
```

**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: "asknicely-send-survey",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    asknicely: { authProvisionId: "apn_xxxxxxx" },
    email: "Email",
    name: "Name",
  },
})

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": "asknicely-send-survey",
    "configured_props": {
      "asknicely": { "authProvisionId": "apn_xxxxxxx" },
      "email": "Email",
      "name": "Name"
    }
  }'
```

---

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