# Example for getting a list of contacts, contact channels, and sending messages on the Respond.io platform

**URL:** <https://community.integray.com/t/example-for-getting-a-list-of-contacts-contact-channels-and-sending-messages-on-the-respond-io-platform/282>\
**Category:** Java script - Node.JS\
**Created:** [July 23, 2024, 11:36am UTC](https://community.integray.com/t/example-for-getting-a-list-of-contacts-contact-channels-and-sending-messages-on-the-respond-io-platform/282 "2024-07-23T11:36:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alevtina.toev](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@alevtina.toev](https://community.integray.com/u/alevtina.toev)\
**Post date:** [July 23, 2024, 11:36am UTC](https://community.integray.com/t/example-for-getting-a-list-of-contacts-contact-channels-and-sending-messages-on-the-respond-io-platform/282/1 "2024-07-23T11:36:30Z")

</div>

Hi! In this example, let’s talk about four other `Respond.io` connectors - **List Contacts** , **List Contact Channels** , **Send Attachment** , and **Send Email**.

* * *

## Prerequisites

Create an account with an email and password at [Respond.io](https://respond.io/) (a confirmation code will be sent to your email, so you must have access to the email).  
Fill in the necessary information in “Let’s set up your organization”.  
Set the first channel (TELEGRAM) by clicking on settings.

 ![HELP_ExampleLibrary_RespondioChannels](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/75cc645cf17492c4957c029294f3a20d77035449.png)

Click on Connect to get to the Telegram connection options.  
Select CREATE A NEW BOT and follow the instructions on how to create a chat bot.  
We get a token from the Bot which we copy into the appropriate field and we can start chatting.  
On `Respond.io` the conversation looks like this:

 ![HELP_ExampleLibrary_Respondio_Telegram_Conversation](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/df2efe36d7c10bcc77986f37c35a945bfbb99e55.png)

In the same way, connect another channel - Gmail.  
Follow the instructions on the [VIDEO](https://app.respond.io/space/228576/settings/channels/connect/all/smtp_gmail).

You also need to enter a list of contacts who will also have channels set up, at least on Telegram. You can enter the contacts manually or use our example [Create, update, or get a contact](https://learn.integray.app/examplelibrary/Respondio/0/).

* * *

We know we have the chats connected and working, so we set up the Integray.  
Add a new Task and name it **List Contacts/Channels, Send Messages**.  
As in the last example, we used the **JS Mapper** , in which we simulated input data. For convenience, we have combined all connectors in one task.  
You can use other connectors and other resources for input data. Also, you can create integrations with each  
`Respond.io` connector separately rather than combining them into one task.

* * *

## List Contacts

Let’s start with the first example, where we use the connector **`Respond.io` - List Contacts** to retrieve a list of contacts from the `Respond.io`. It is useful for managing and viewing all the contact information you have stored. By using this connector, you can filter and sort contacts based on various criteria, helping you efficiently manage your contact database.

### Configuration

Add a first Task step:

- Step name: Input Data
- Connector: **JS Mapper**

 ![HELP_ExampleLibrary_Respondio_ListContacts_FirstStep](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/8977bfeeb0a799e7f5cb3c0d65cabd0fc8efb0bc.png)

Open the step’s Task step editor by clicking the button with the pencil symbol.

Insert the following code into the JS Mapping statement configuration:

```JSON
return [
  {
    "Filters":
    {
      "FilterAnd": []
    },
    "Search": "",
    "Timezone": "Asia/Kuala_Lumpur"
  }
]

```

Select the Output schema **`Respond.io` - List Contacts Request** , which is the mandatory input schema.  
The setting of the first step can look like follows:

 ![HELP_ExampleLibrary_Respondio_ListContacts_FirstStepConfiguration](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/6a80522a1c08271e2e65b7169b971eb8a395a956.png)

Add a second Task step:

- Step name: List Contacts
- Connector: **`Respond.io` - List Contacts**

Open the step’s Task step editor.  
Pin input mapping.  
Fill in the token - find it after the instructions here: [API Respond.io](https://help.respond.io/l/en/integrations/developer-api).  
Save the configuration.  
Select error behavior and save the configuration again.

 ![HELP_ExampleLibrary_Respondio_ListContacts_InputMapping](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/baebbc0623b8ad34082e7306ae97fb1ce90d80f2.png)

Press the **Publish** button.  
Start the task.

### Result - list of contacts retrivied

As a result, we get a list of our contacts.  
This is the result in Integray.

 ![HELP_ExampleLibrary_Respondio_ListContacts_Dataviewer](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/9614a778bdf09c95d34825a391b6b1f694e805b6.png)

* * *

## List Contact Channels

The **List Contact Channels** connector lists all the communication channels associated with each contact. It provides insights into the different ways you can reach out to your contacts, such as through email, phone, or social media. This is particularly useful for understanding the preferred communication methods of your contacts and ensuring you use the right channels for your messages.

### Configuration

In the third step, we again have a **JS Mapper** in which we filtered all users who have active conversations in `Respond.io`.

Add a third Task step:

- Step name: Prepare identifier for Channels List
- Connector: **JS Mapper**

Open the step’s Task step.

Insert the following code into the JS Mapping statement configuration:

```JSON
const contactPhones = inputData[0].Items;
 
let output = contactPhones
  .filter((item) => item.Phone !== null)
  .map((item) => {
    return { "Identifier": `phone:${item.Phone}` };
  });
 
return output;

```

The name of Input schema **`Respond.io` - List Contacts Response**.  
The name of Output schema **`Respond.io` - List Contact Channels Request**.  
Pin input mapping.

The setting of the third step can look like follows:

 ![HELP_ExampleLibrary_Respondio_ListContact_ThirdStep](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/ef679a055114f33de5b0f0aa7e2bbcac4d085f5a.png)

Add a fourth Task step:

- Step name: List Contacts channels
- Connector: **`Respond.io` - List Contacts Channels**

Open the step’s Task step editor.  
Pin input mapping.  
Fill in the token.  
Save the configuration.  
Select error behavior and save the configuration again.

 ![HELP_ExampleLibrary_Respondio_ListContactsChannels_InputMapping](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/4d454c9f5cc73b62bb1d8f235c990608659bdb8e.png)

Press the **Publish** button.  
You can start the task to see the result.

### Result - list of contacts channels retrivied

As a result, we get a list of our contacts.  
This is the result in Integray.

 ![HELP_ExampleLibrary_Respondio_ListContactChannels_Dataviewer](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/2c3d73c02c8bcdac3754c64336df320d09a4f8a3.png)

* * *

## Send Attachment

The **Send Attachment** connector enables you to send files to your contacts through supported messaging channels. This is particularly useful for sharing documents, images, or other files directly with your contacts. You can specify the recipient, the type of attachment, and other relevant details to ensure the file is delivered appropriately.

To send an attachment, we will also use **JS Mapper** where we prepare a message. This message is for both email and Telegram and is structured as required. We use the multi input step (MIS). It is a new feature introduced in Integray to enhance the flexibility and efficiency of data integration workflows. More about MIS [here](https://learn.integray.app/knowledgebase/configurationscreen/tasks/multiinputstep/).

### Configuration

Add a fifth Task step:

- Step name: Prepare message
- Connector: **JS Mapper**

Open the step’s Task step editor.

Insert the following code into the JS Mapping statement configuration:

```JSON
return [{
  "Identifier": "phone:+42 **********",
  "ChannelID": 123456,
  "Type": "image", 
  "Url": "https://www.shutterstock.com/image-photo/black-white-whippet-lurcher-dog-260nw-1573558528.jpg",
  "Subject": "Peso",
  "Text": "Pekny peso"
}]

```

- `Identifier` - contact identifier, which can be either a phone number, email, or contact ID (we get the contact ID after saving the contact, so it is used in case of editing the contact). The identifier is mandatory
- `Channel id` - from channel settings
- `Type` - format type - allowed : image, video, audio, file
- `Url` - url of the page where the file is located

The name of Input schema **`Respond.io` - List Contact Channels Response**.  
Output schema is not configured by default. Create it manually, depending on the data you send from the JS Statement. Save it and Load the schema.

In our case, the schema looks like this:

 ![HELP_ExampleLibrary_Respondio_SendAttachment_Outputschema](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/c5c60fcea336c53c00188d95b11159111caf8b4b.png)

Pin input mapping. Note that we used a filter for ID.

 ![HELP_ExampleLibrary_Respondio_ListContact_FifthStep_PinnedInput](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/4021aeb1a6fc86de2fa7843e1717398222666828.png)

Add a sixth Task step:

- Step name: Send Attachment
- Connector: **`Respond.io` - Send Attachment**

Open the step’s Task step editor.  
Pin input mapping.

 ![HELP_ExampleLibrary_Respondio_SendAttachment_InputMapping](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/fbb99f216a002c99d8e14624d69bc5d433c5274d.png)

Fill in the token.  
Save the configuration.  
Select error behavior and save the configuration again.  
Press the **Publish** button.  
Start the task to see the result.

### Result - list of contacts channels retrivied

The result should be that the image (or any other file that is available at the specified URL in the JS Mapper statement) is displayed in the conversation on `Respond.io` as a message directly from `Respond.io`.

This is the result in Integray.

 ![HELP_ExampleLibrary_Respondio_SendAttachment_SixStepDataViewer](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/c5044f5f5056f52f860de02a37f05afda85cdd83.png)

## Send Email

The **Send Email** connector facilitates sending emails to your contacts. It allows you to craft email messages within the platform and send them to your contact list. You can customize the email content, subject, and recipients, making it a powerful tool for communication and marketing campaigns.

### Configuration

We will use the incoming data from the previous step with the connector JS Mapper, for this purpose we will also use the new MIS feature.

Add the last, seventh step.  
Do this by clicking on the plus sign on the side of step six. This will create a branch.

 ![HELP_ExampleLibrary_Respondio_SendEmail_CreateNewBranch](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/f0530350af5f26a0c273857617d3a6b7c5f0cd86.png)

Now we need to make some changes in step five.

Open step five, click on the plus sign in the Input schema to add an additional schema.  
Add a Prepare identifier for Channels List, also note the Input Processing - Bulk, the color of the icon automatically will change from blue to purple.  
Pin input mapping.

 ![HELP_ExampleLibrary_Respondio_SendEmail_AddMultiInputSchema](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/3b23cada46ab4f3b854548833c9f8fbb69ffd052.png)

Press the **Publish** button.  
Start the task to see the result.

### Result - Email sended - Email retrivied

The result should be that the email entered in Intgeray along with the email definition in the statement will arrive in the inbox of the corresponding email and will also appear in the conversation on `Respond.io` as a message directly from `Respond.io`.

The task ran successfully, with all steps tinted green.

 ![HELP_ExampleLibrary_Respondio_ListContacts_TaskFinishedSuccess](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/584149a35ba55b28c132c9345fc88d3a3cc2ff76.png)

 ![HELP_ExampleLibrary_Respondio_SendEmail_Dataviewer](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/71516716010681445a678615ce3261626f621740.png)

On the `Respond.io`, we see that the picture is received from email to email.

 ![HELP_ExampleLibrary_Respondio_SendEmail_ResultOnRespondio](https://europe1.discourse-cdn.com/flex017/uploads/integray/original/1X/485c389a7a1d6a84a40f4b5893e8d2b6caf0f68c.png)

* * *

We are happy if you got the expected result. You can create your own new integrations based on this example.
