← Freshchat + WATI integrations

Add Contact with WATI API on New Message Received from Freshchat API

Pipedream makes it easy to connect APIs for WATI, Freshchat and 2,900+ other apps remarkably fast.

Trigger workflow on
New Message Received from the Freshchat API
Next, do this
Add Contact with the WATI API
No credit card required
Intro to Pipedream
Watch us build a workflow
Watch us build a workflow
8 min
Watch now ➜

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

Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo
Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo

Developers Pipedream

Getting Started

This integration creates a workflow with a Freshchat trigger and WATI action. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Select this integration
  2. Configure the New Message Received trigger
    1. Connect your Freshchat account
    2. Configure timer
    3. Select a User ID
    4. Select a Conversation ID
  3. Configure the Add Contact action
    1. Connect your WATI account
    2. Configure WhatsApp Number
    3. Optional- Configure Name
    4. Optional- Configure Custom Params
  4. Deploy the workflow
  5. Send a test event to validate your setup
  6. Turn on the trigger

Details

This integration uses pre-built, source-available components from Pipedream's GitHub repo. These components are developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Trigger

Description:Emit new event when a new message is received in a conversation. [See the documentation](https://developers.freshchat.com/api/#list_messages)
Version:0.0.1
Key:freshchat-new-message-received

Trigger Code

import common from "../common/base.mjs";
import sampleEmit from "./test-event.mjs";

export default {
  ...common,
  key: "freshchat-new-message-received",
  name: "New Message Received",
  description: "Emit new event when a new message is received in a conversation. [See the documentation](https://developers.freshchat.com/api/#list_messages)",
  version: "0.0.1",
  type: "source",
  dedupe: "unique",
  props: {
    ...common.props,
    userId: {
      propDefinition: [
        common.props.freshchat,
        "userId",
      ],
    },
    conversationId: {
      propDefinition: [
        common.props.freshchat,
        "conversationId",
        (c) => ({
          userId: c.userId,
        }),
      ],
    },
  },
  methods: {
    ...common.methods,
    _getLastCreatedTime() {
      return this.db.get("lastCreatedTime");
    },
    _setLastCreatedTime(time) {
      this.db.set("lastCreatedTime", time);
    },
    generateMeta(message) {
      return {
        id: message.id,
        summary: `New message received: ${message.id}`,
        ts: Date.parse(message.created_time),
      };
    },
    async processEvents(max) {
      const lastCreatedTime = this._getLastCreatedTime();
      let maxCreatedTime = lastCreatedTime;

      const results = this.freshchat.paginate({
        fn: this.freshchat.listMessages,
        args: {
          conversationId: this.conversationId,
        },
        resourceKey: "messages",
      });

      let messages = [];
      for await (const message of results) {
        if (!lastCreatedTime || Date.parse(message.created_time) > Date.parse(lastCreatedTime)) {
          if (!maxCreatedTime || Date.parse(message.created_time) > Date.parse(maxCreatedTime)) {
            maxCreatedTime = message.created_time;
          }
          messages.push(message);
        }
      }
      this._setLastCreatedTime(maxCreatedTime);

      if (max) {
        messages = messages.slice(0, max);
      }

      for (const message of messages) {
        this.$emit(message, this.generateMeta(message));
      }
    },
  },
  sampleEmit,
};

Trigger Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
FreshchatfreshchatappThis component uses the Freshchat app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between executions.
timer$.interface.timer
User IDuserIdstringSelect a value from the drop down menu.
Conversation IDconversationIdstringSelect a value from the drop down menu.

Trigger Authentication

Freshchat uses API keys for authentication. When you connect your Freshchat account, Pipedream securely stores the keys so you can easily authenticate to Freshchat APIs in both code and no-code steps.

About Freshchat

Customer Messaging, Live Chat & Chatbots

Action

Description:Adds a new contact on the WATI platform. [See the documentation](https://docs.wati.io/reference/post_api-v1-addcontact-whatsappnumber)
Version:0.0.2
Key:wati-add-contact

WATI Overview

The WATI API allows you to power up your customer engagement by leveraging WhatsApp messaging. With Pipedream's capabilities, you can create serverless workflows that integrate WATI to automate personalized notifications, process inbound messages, and manage contacts. This can help scale your customer service, marketing campaigns, and streamline communications with WhatsApp's wide user base.

Action Code

import { ConfigurationError } from "@pipedream/platform";
import wati from "../../wati.app.mjs";

export default {
  key: "wati-add-contact",
  name: "Add Contact",
  description: "Adds a new contact on the WATI platform. [See the documentation](https://docs.wati.io/reference/post_api-v1-addcontact-whatsappnumber)",
  version: "0.0.2",
  annotations: {
    destructiveHint: false,
    openWorldHint: true,
    readOnlyHint: false,
  },
  type: "action",
  props: {
    wati,
    whatsappNumber: {
      propDefinition: [
        wati,
        "whatsappNumber",
      ],
    },
    name: {
      type: "string",
      label: "Name",
      description: "The name of the contact",
      optional: true,
    },
    customParams: {
      propDefinition: [
        wati,
        "customParams",
      ],
      optional: true,
    },
  },
  async run({ $ }) {
    const response = await this.wati.addContact({
      $,
      whatsappNumber: this.whatsappNumber,
      data: {
        name: this.name,
        customParams: this.customParams && Object.entries(this.customParams).map(([
          key,
          value,
        ]) => ({
          name: key,
          value,
        })),
      },
    });
    if (!response.result) {
      throw new ConfigurationError(response.info);
    }
    $.export("$summary", `Successfully added contact with phone number: ${this.whatsappNumber}`);
    return response;
  },
};

Action Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI.

LabelPropTypeDescription
WATIwatiappThis component uses the WATI app.
WhatsApp NumberwhatsappNumberstring

Your WhatsApp number with country code.

Namenamestring

The name of the contact

Custom ParamscustomParamsobject

An object with contact's custom fields.

Action Authentication

WATI uses API keys for authentication. When you connect your WATI account, Pipedream securely stores the keys so you can easily authenticate to WATI APIs in both code and no-code steps.

To retrieve your Access Token and API Endpoint,

  • Navigate to your WATI account and sign in
  • Click the Navigation menu on top bar with the three horizontal lines icon
  • Go to “API Docs”

Copy and paste your Access Token and API Endpoint below.

About WATI

#1 Platform For Marketing & Customer Engagement On WhatsApp

More Ways to Connect WATI + Freshchat

Fetch Conversation Details with Freshchat API on New Contact Created from WATI API
WATI + Freshchat
 
Try it
Fetch Conversation Details with Freshchat API on New Incoming Message from WATI API
WATI + Freshchat
 
Try it
List Channels with Freshchat API on New Contact Created from WATI API
WATI + Freshchat
 
Try it
List Channels with Freshchat API on New Incoming Message from WATI API
WATI + Freshchat
 
Try it
Update Conversation Status with Freshchat API on New Contact Created from WATI API
WATI + Freshchat
 
Try it
New Conversation Started from the Freshchat API

Emit new event when a new conversation is started for a user. See the documentation

 
Try it
New Message Received from the Freshchat API

Emit new event when a new message is received in a conversation. See the documentation

 
Try it
New Contact Created from the WATI API

Emit new event when a contact is created from an incoming WhatsApp message.

 
Try it
New Incoming Message from the WATI API

Emit new event when there is an incoming message on your number.

 
Try it
Fetch Conversation Details with the Freshchat API

Fetches details for a specific conversation. See the documentation

 
Try it
List Agents with the Freshchat API

Lists all agents in Freshchat. See the documentation

 
Try it
List Channels with the Freshchat API

Lists all channels in Freshchat. See the documentation

 
Try it
Send Message in Chat with the Freshchat API

Sends a message in a specific conversation. See the documentation

 
Try it
Update Conversation Status with the Freshchat API

Updates the status of a specific conversation. See the documentation

 
Try it

Explore Other Apps

1
-
24
of
2,900+
apps by most popular

Node
Node
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Python
Python
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
Notion
Notion
Notion is a new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team.
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular models like ChatGPT, DALL-E, and Whisper.
Anthropic (Claude)
Anthropic (Claude)
AI research and products that put safety at the frontier. Introducing Claude, a next-generation AI assistant for your tasks, no matter the scale.
Google Sheets
Google Sheets
Use Google Sheets to create and edit online spreadsheets. Get insights together with secure sharing in real-time and from any device.
Telegram
Telegram
Telegram, is a cloud-based, cross-platform, encrypted instant messaging (IM) service.
Google Drive
Google Drive
Google Drive is a file storage and synchronization service which allows you to create and share your work online, and access your documents from anywhere.
HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Google Calendar
Google Calendar
With Google Calendar, you can quickly schedule meetings and events and get reminders about upcoming activities, so you always know what’s next.
Schedule
Schedule
Trigger workflows on an interval or cron schedule.
Pipedream Utils
Pipedream Utils
Utility functions to use within your Pipedream workflows
Shopify
Shopify
Shopify is a complete commerce platform that lets anyone start, manage, and grow a business. You can use Shopify to build an online store, manage sales, market to customers, and accept payments in digital and physical locations.
Supabase
Supabase
Supabase is an open source Firebase alternative.
MySQL
MySQL
MySQL is an open-source relational database management system.
PostgreSQL
PostgreSQL
PostgreSQL is a free and open-source relational database management system emphasizing extensibility and SQL compliance.
Premium
AWS
AWS
Amazon Web Services (AWS) offers reliable, scalable, and inexpensive cloud computing services.
Premium
Twilio SendGrid
Twilio SendGrid
Send marketing and transactional email through the Twilio SendGrid platform with the Email API, proprietary mail transfer agent, and infrastructure for scalable delivery.
Amazon SES
Amazon SES
Amazon SES is a cloud-based email service provider that can integrate into any application for high volume email automation
Premium
Klaviyo
Klaviyo
Email Marketing and SMS Marketing Platform
Premium
Zendesk
Zendesk
Zendesk is award-winning customer service software trusted by 200K+ customers. Make customers happy via text, mobile, phone, email, live chat, social media.
Premium
ServiceNow
ServiceNow
The smarter way to workflow
Slack
Slack
Slack is the AI-powered platform for work bringing all of your conversations, apps, and customers together in one place. Around the world, Slack is helping businesses of all sizes grow and send productivity through the roof.
Microsoft Teams
Microsoft Teams
Microsoft Teams has communities, events, chats, channels, meetings, storage, tasks, and calendars in one place.