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

@tomyjwu/grpcflow-client

v0.1.2

Published

client lib to call grpcflow

Downloads

2

Readme

grpcflow

inspired by https://github.com/grpc-ecosystem/grpc-cloud-run-example

This packaged gRPC client for Dialogflow webhook as a library, to hide the grpc proto loading, connecting server, ...etc details

usage

// prepare Dialogflow webhook inline editor request json as parameter
const grpcflow = require('@tomyjwu/grpcflow-client');
grpcflow(argv.server, argv.plaintext, request).then((value) => {
      console.log(value);
    }, (error) => {
      console.error(error);
    });

testing cli example

 node testcli.js --server="localhost:50061" --intent="get-agent-name" --plaintext

full example for Dialogflow inline editor

server code

please visit https://github.com/tomyjwu/python-grpcflow for example python server to receive the grpc Dialogflow request. Following sample assumed the server is deployed to google cloud run.

you should replace grpcflowServer with your server/api address.

const grpcflowServer = "grpcflow-server-xyspwhk3xq-uc.a.run.app";

index.js

// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';

const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const grpcflow = require('@tomyjwu/grpcflow-client');

process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
 const flowRequest = request.body;
 const agent = new WebhookClient({ request, response });
 console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
 console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
 
 function grpcflowHandler(agent) {
   const grpcflowServer = "grpcflow-server-xyspwhk3xq-uc.a.run.app";
     return grpcflow(grpcflowServer, false, flowRequest)
   .then((value) => {
     const fulfillmentText = value.fulfillmentMessages.text.text[0];
     agent.add(`From fulfillment ok=${fulfillmentText}`);
     console.log('calc result:' + value);
   }, (error) => {
     agent.add(`From fulfillment fail=${error}: My name is Dialogflow!`);
   });
 }
 agent.handleRequest(grpcflowHandler);
});

package.json

{
  "name": "dialogflowFirebaseFulfillment",
  "description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "author": "Google Inc.",
  "engines": {
    "node": "8"
  },
  "scripts": {
    "start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
    "deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
  },
  "dependencies": {
    "actions-on-google": "^2.2.0",
    "firebase-admin": "^5.13.1",
    "firebase-functions": "^2.0.2",
    "dialogflow": "^0.6.0",
    "dialogflow-fulfillment": "^0.5.0",
    "@tomyjwu/grpcflow-client": "^0.1.0"
  }
}