npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dialogflow-connector

v1.0.0

Published

Custom channel connector for Dialogflow CX

Downloads

7

Readme

Dialogflow CX: Social Media Channels Connector

The Dialogflow CX is a great place to build more complex conversational assistants. But one of the challenges that developers face is that of limited channel support. At present, it only supports several telephony partners and beta support for Dialogflow messenger (web platform).

The dialogflow-connector focuses to provide different social media channel connections that you can use with your Dialogflow CX agent. You can focus on designing the agent with responses as custom payloads.

Right now we provide support for only the below channels:

  • Facebook messenger

Quickstart

Before you begin

Installing the library

Install the library with npm

npm install dialogflow-connector --save

Using the client library

As part of the Before you begin step, you have set-up the authentication with a service account. Now, you have to set-up some other environment variables for your application.

  • DIALOGFLOW_PROJECT_ID (The project id the agent uses)
  • DIALOGFLOW_AGENT_LOCATION (The location that the agent uses. You can set this variable as global or any other specific location that you want to use.)
  • DIALOGFLOW_AGENT_ID (The dialogflow agent id which can be found in the service account that you have created.)

Now, create a file named index.js or any name that you preder and paste the below script with the facebook app and page credentials to connect with dialogflow agent.

const { Connector } = require('dialogflow-connector')

const ChannelConnector = new Connector({
    webhook_uri: '/api/messages',
    chennels: {
        'facebook': {
            verify_token: <FACEBOOK_VERIFY_TOKEN>,
            access_token: <FACEBOOK_ACCESS_TOKEN>
        }
    }
})

Now, run the application with ngrok and you can now receive the facebook events from your page using the ngrok tunnel.

Supported Message Types

  • Simple Text messages
  • Quick replies
  • Button Template
  • Generic Template

Custom Payload Structure

For the simple text messages, you can define the responses as normal text responses in the agent.

Quick replies

{
    "facebook": {
        "quick_replies": [
            {
                "text": "Reply 1",
                "payload": "PayloadOne"
            },
            {
                "text": "Reply 2",
                "payload": "PayloadTwo"
            }
        ],
        "text": "These are quick replies."
    }
}

Button template

{
    "facebook": {
        "attachment": {
            "payload": {
                "template_type": "button",
                "text": "This is button template.",
                "buttons": [
                    {
                        "payload": "PayloadOne",
                        "title": "Button 1",
                        "type": "postback"
                    },
                    {
                        "url": "https://github.com/gpjyothish/dialogflow-connector",
                        "title": "Open Page",
                        "type": "web_url"
                    }
                ]
            },
            "type": "template"
        }
    }
}

Generic Template

{
    "facebook": {
        "attachment": {
            "payload": {
                "template_type": "generic",
                "elements": [
                    {
                        "buttons": [
                            {
                                "payload": "ButtonPayload",
                                "title": "Button Name",
                                "type": "postback"
                            }
                        ],
                        "title": "Sample Card 1",
                        "subtitle": "Sample subtitle",
                        "image_url": "https://ibb.co/rsg2q5t"
                    },
                    {
                        "buttons": [
                            {
                                "url": "https://github.com/gpjyothish/dialogflow-connector",
                                "title": "Open Page",
                                "type": "web_url"
                            }
                        ],
                        "title": "Sample Card 2",
                        "subtitle": "Sample subtitle",
                        "image_url": "https://ibb.co/rsg2q5t"
                    }
                ]
            },
            "type": "template"
        }
    }
}