Code Monkey home page Code Monkey logo

chat-api-daemon's Introduction

chat-api-daemon

This projects provides multiple apis to access whatsapp using the php chat-api library. Once setup you can use it to send and receive whatsapp messages in your code using websockets or http.

About / motivation

Chat-api provides a great way to interact with whatsapp from php code. But since its coded in php you can only use it in php projects. To remove this limitation this projects provides an RPC like interface to chat-api so you can use it in nearly any language you can imagine.

Quick start

Before you can start you have to obtain a whatsapp username and password for the api. Have a look at the chat-api documation for this. If you have these two you can run our docker container:

docker run -it --rm -p 127.0.0.1:8080:8080 -p 127.0.0.1:8081:8081 -e "NUMBER=your_number" -e "PASSWORD='whatsapp_password'" -v $(pwd)/wadata:/app/client/vendor/whatsapp/chat-api/src/wadata mawalu/chat-api-daemon

Replace the environment variables with your values and after everything is downloaded you should be ready to go.

Message format

All function calls and events are formated in the same way:

{"method": "someMethode", "args":["arg1", "arg2"]}

You can get a list of all functions, events and their arguments here and here.

Usage

You can access the daemon using websockets or http. If you want to test the websocket connection you can install wscat and try

wscat -c ws://127.0.0.1:8081

if everything is ok you should see all the events fired by chat-api. You can also call api functions if you format them like described above.

To trigger methods over http you can do something like:

curl -H "Content-Type: application/json" -X POST -d '{"method":"sendMessage","args":["12344356", "hello world"]}' http://127.0.0.1:8080

If you want to receive http notifications via webhooks, set a environment variable called CALLBACK_URLS to a comma separated list of urls. (I can recommend requestb.in to test webhooks)

To use this from your favorite language you have to look up how to use http or websockets there and decide which one suits you better.

Advanced options

Run as service

To run the docker container in the background and autostart it after a reboot use the following command:

docker run -d --restart=always -p 127.0.0.1:8080:8080 -p 127.0.0.1:8081:8081 -e "NUMBER=your_number" -e "PASSWORD='whatsapp_password'" -e "WEBSOCKET_PORT=8081" -e "HTTP_PORT=8080" -v $(pwd)/wadata:/app/client/vendor/whatsapp/chat-api/src/wadata mawalu/chat-api-daemon

Use without docker

To run the code without docker you have to install all the dependencies for chat-api, the composer & npm dependencies from this project and set all the config values as environment variables in your shell. After that you can run the index.js script in the server directory using node.js.

Terms and conditions

As with chat-api itself:

  • You will NOT use this API for marketing purposes (spam, massive sending...).
  • We do NOT give support to anyone that wants this API to send massive messages or similar.
  • We reserve the right to block any user of this repository that does not meet these conditions.

Legal

This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by WhatsApp or any of its affiliates or subsidiaries.

chat-api-daemon's People

Contributors

mawalu avatar

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.