Giter Club home page Giter Club logo

chat21-cloud-functions's Introduction

Chat21 - Firebase Cloud Functions

npm version

Chat21 is the core of the open source live chat platform Tiledesk.com.

Introduction

Chat21-cloud function is the backend module required for the operation of the other chat21 modules.

  • Send a direct message
  • Send a group message
  • Create a conversation for each message
  • Send the push notification for direct and group message
  • Send an info message to notify the creation of a group or a member joining

Pre requisites

You can find more info about Firebase Functions here https://firebase.google.com/docs/functions/get-started

Project building

git clone [email protected]:chat21/chat21-cloud-functions.git
cd functions
npm install

Project setup

  1. Login on the Firebase CLI with firebase login - it requires access to a web browser.

    • To log into the CLI in remote environments that don't allow access to localhost, use the --no-localhost flag. firebase login --no-localhost More info here https://firebase.google.com/docs/cli/
  2. Set up your Firebase project by running firebase use --add, select your Project ID

Deploy

Deploy to Firebase using the following commands:

  1. Go in the project root directory with

    cd ..
  2. Deploy

    firebase deploy

You can now see the deployed functions on the Firebase Console under Functions menu.

Tips

Run with Docker

If you prefer you can use a pre-built docker image to deploy the cloud functions to the Firebase project:

Run:

docker run -it chat21/chat21-cloud-functions sh

After that follow the "Project setup" and "Deploy paragraphs.

Test

Send your first message

  • Create a new user on the Firebase Console under Authentication Menu.
  • Select Email/Password for Authentication Provider
  • Click on "Add New User" and populate Email and Password field with for example : email = [email protected], password = 123456
  • Get a JWT token calling JWT Authentication method as described here JWT Authentication
  • Send a new message using Send Message API with JWT Authentication as described here Send message

Advanced Setup Options

Read the Setup Options page

REST API

Read the REST API page

chat21-cloud-functions's People

Contributors

andrealeo83 avatar gianpaj avatar sponzillo avatar stefanodp91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chat21-cloud-functions's Issues

Ionic 4/5 and API methods

Is there an example for Ionic 4/5?
I read the API documentation but found no methods to retrieve chats just to send a message.

Thanks

Getting 400 when dashboard is looking for /proj_id/requests/support-group-id

How are request being saved if this is commented out in functions/chat-support.api
I am having issues getting requests to be saved in mongo which is preventing agents from replying to mesages

//Save to mongo

// if (functions.config().support.storetobackend && functions.config().support.storetobackend.enabled && functions.config().support.storetobackend.enabled=="true") {
//     console.log('support.storetobackend', 'enabled');

//     return chatSupportApi.createRequest(projectid, newRequest);
   
// }else {
//     console.log('support.storetobackend', 'disabled');
// }

error parsing triggers

Hi when i try to deploy de functions i get this error "Error parsing triggers: Cannot find module 'firebase-functions'". log is this:
=== Deploying to 'firechat-dbb28'...

i deploying database, functions
i database: checking rules syntax...
✔ database: rules syntax for database firechat-dbb28 is valid
i functions: ensuring necessary APIs are enabled...
⚠ functions: missing necessary APIs. Enabling now...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...

Error: Error parsing triggers: Cannot find module 'firebase-functions'

Any helps please?

Documentation on how to receive messages ??

Heylo,

very nice project by the way. I am missing some documentation on how messages are received. I saw that in the demo there is an API call for GET .../api/.../messages but I don't see this in the chat-api function nor does a GET work on this endpoint with my deployment.

  • code21-node-sdk

Any hint on where is can find some doc, code, or info on how to receive messages?

Unnecessary notification when joining group

The function in index.js duplicateTimelineOnJoinGroup triggers the function sendNotification in push-notification.js. So if someone joins a group chat with 1000 users, the user gets 1000 push notifications from system. Is there a way to stop this?

package.json missing

I have clone the project now when I install it I get an error package.json not found. Can you provide me the json required to this file? Waiting for your reply..

Node.js 8 has been deprecated in Firebase

Node.js 8 has been deprecated.
From 15 Feb 2021, we'll no longer support new deploys or updates of Node.js 8 functions.
Starting 15 Mar 2021, we'll no longer support executions of existing Node.js 8 functions.

Chat 21 Cloud Function Setup

Nice work guys, nice work.

In your doc, you said.
"Project setup
Clone or download this repo from github
Run from command line:
cd functions
npm install"

..now I'm guessing this should be after Firebase login right?
the cd functions should also be in the cmd cli (function directory) after selecting the project on fire-base in question?

where does "npm install come in?" and what target is the install? Is it the selected project in the firestore or something else?

Overall, please kindly clarify how these cloud functions should be properly run on firebase cloud service.

Thank you

Getting Error on firebase deploy

Setup time error after : firebase deploy

⚠ functions[thumbnailFunction-generateThumbnail(us-central1)]: Deployment error.
Failed to configure trigger GCS Bucket: support-b3bbf.appspot.com

When i am doing manually setup : firebase deploy --only functions:thumbnailFunction-generateThumbnail

it shows error in details

⚠ functions: package.json indicates an outdated version of firebase-functions.
Please upgrade using npm install --save firebase-functions@latest in your functions directory.

=== Deploying to 'support-b3bbf'...

i deploying functions
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (97.87 KB) for uploading
✔ functions: functions folder uploaded successfully
i functions: current functions in project: api(us-central1), createConversation(us-central1), deleteArchivedConversation(us-central1), duplicateTimelineOnJoinGroup(us-central1), duplicateTimelineOnJoinGroupForInvitedMembers(us-central1), fanOutGroup(us-central1), insertAndSendMessage(us-central1), pushNotificationsFunction-sendNotification(us-central1), removeMemberInfoOnLeaveGroup(us-central1), saveMemberInfoOnJoinGroup(us-central1), sendInfoMessageOnGroupCreation(us-central1), sendInfoMessageOnJoinGroup(us-central1), sendMessageReturnReceipt(us-central1), thumbnailFunction-generateThumbnail(us-central1)
⚠ functions: the following filters were specified but do not match any functions in the project: thumbnailFunction-generateThumbnail

✔ Deploy complete!

This is the error i am getting in firebase console

12:43:55.665 pm | warning | thumbnailFunction-generateThumbnail | {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":13,"message":"INTERNAL"},"authenticationInfo":{"principalEmail":"[email protected]"},"requestMetadata":{"requestAttributes":{},"destinationAttributes":{}},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/support-b3bbf/locations/us-central1/functions/thumbnailFunction-generateThumbnail"}

Anyone can help me to solve this. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.