Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lopezjurip/chat-intent
Parse phone number to create intents for chat apps
https://github.com/lopezjurip/chat-intent
Last synced: 25 days ago
JSON representation
Parse phone number to create intents for chat apps
- Host: GitHub
- URL: https://github.com/lopezjurip/chat-intent
- Owner: lopezjurip
- Created: 2017-07-28T14:15:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-05T11:36:59.000Z (about 7 years ago)
- Last Synced: 2024-10-12T09:14:56.326Z (26 days ago)
- Language: JavaScript
- Homepage:
- Size: 85.9 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# chat-intent
[![dependencies][dependencies-image]][dependencies-url] [![dev-dependencies][dev-dependencies-image]][dev-dependencies-url] [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
## Getting started
Install the main `chat-intent` and the middleware you may need as `chat-intent-whatsapp` and `chat-intent-telegram`:
```sh
yarn add chat-intent chat-intent-whatsapp chat-intent-telegram
```Create URIs, URLs and parsed phone number:
```js
const ChatIntent = require("chat-intent").default;
const intentWhatsapp = require("chat-intent-whatsapp").default;
const intentTelegram = require("chat-intent-telegram").default;const intent = new ChatIntent();
intent.use(ChatIntent.middleware.validate());
intent.use(ChatIntent.middleware.encodeText());
intent.use(intentWhatsapp());
intent.use(intentTelegram());const { result } = intent.generate("+56 9 8765 4321", { text: "Hello World!" });
console.log(result);
```Output
```json
{
"identifier": "56987654321",
"phone": "+56 9 8765 4321",
"country": "CL",
"code": "56",
"valid": true,
"whatsapp": {
"browser": "https://web.whatsapp.com/send?phone=56987654321&text=Hello+World!",
"native": "whatsapp://send?phone=56987654321&text=Hello+World!"
},
"telegram": {
"native": "tg://msg?to=+56987654321&text=Hello+World!"
}
}
```## Development
Clone and install dependencies:
```sh
git clone https://github.com/mrpatiwi/chat-intent.git
cd chat-intent
yarn
```[dependencies-image]: https://david-dm.org/mrpatiwi/chat-intent.svg
[dependencies-url]: https://david-dm.org/mrpatiwi/chat-intent
[dev-dependencies-image]: https://david-dm.org/mrpatiwi/chat-intent/dev-status.svg
[dev-dependencies-url]: https://david-dm.org/mrpatiwi/chat-intent#info=devDependencies