115 lines
4.3 KiB
HTML

<script type="text/javascript">
RED.nodes.registerType('chats-out',{
category: 'whatsapp',
color: '#25D366',
defaults: {
name: {value:"Chats Out"},
whatsappLink: {value:"whatsapp-web", type:'whatsappLink'},
recipient: {value:"", type:'numberRecipient', required:false}
},
outputs:0,
inputs:1,
icon: 'whatsappLink.svg',
align: 'right',
label: function() {
return this.name||"Chats Out";
}
});
</script>
<script type="text/html" data-template-name="chats-out">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-whatsappLink"><i class="fa fa-gear"></i> Client</label>
<input type="text" id="node-input-whatsappLink" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-recipient"><i class="fa fa-user"></i> Recipient</label>
<input type="text" id="node-input-recipient" placeholder="Select or add recipient">
</div>
<div class="form-tips">
<p><b>Recipient:</b> Select a reusable Number Recipient configuration (optional).</p>
<p><b>Override at runtime:</b> Provide <code>msg.toNumber</code> to override the configured recipient.</p>
<p>Number format: <b>+11 99999 99999</b> (international dialing code, no spaces).</p>
<p>For multiple contacts, pass an array: <code>msg.toNumber = ["+1199999999", "+12990000099"]</code></p>
</div>
</script>
<script type="text/markdown" data-help-name="chats-out">
Node to send whatsapp messages.
As simple as mention on name, node will send `msg.payload` recived at input to the number mentioned in node.
MultiMedia Message Out: Requirments-
| Input | Description |
|--------|-------------|
| `msg.image` | Base64 (encoded image) |
| `msg.payload` | Image Caption |
| `msg.toNumber` | Reciver number (if number not provided in node) |
## Button, List and TemplateButton
Supported in Whatsapp-Lite only, `TODO for Whatsapp-Web`.
* <b>Simple Button </b>For simple 3 Bottons your `msg.paylod` should be...
```js
msg.payload = {
text: "Hi it's button message", //String
footer: 'Hello World', //String
headerType: 1, //keep it "1" only.
buttons: [ // Array of buttons.
{buttonId: 'id1', buttonText: {displayText: 'Button 1'}, type: 1},
{buttonId: 'id2', buttonText: {displayText: 'Button 2'}, type: 1},
{buttonId: 'id3', buttonText: {displayText: 'Button 3'}, type: 1}
]
}
```
* <b>TemplateButton</b> combination of <b>link button</b>, <b>Call button</b> and Normal buttons. Your `msg.paylod` should look similar to--
```js
msg.payload = {
text: "Hi it's a template message by Node-RED 👍 to Test",
footer: 'Hello I am footer of message.',
templateButtons: [
{index: 1, urlButton: {displayText: '⭐ Vist Node-RED', url: 'https://nodered.org/'}},
{index: 2, callButton: {displayText: 'Call me!', phoneNumber: '+1 (234) 5678-901'}},
{index: 3, quickReplyButton: {displayText: 'Click me I am Button', id: 'I-am-button-id-without-space'}},
{index: 4, quickReplyButton: {displayText: '🖱️ Sample Button 2', id: 'button-2-was-clicked'}}
]
}
```
* <b>List Message</b> combination of <b>link button</b>, <b>List button</b> and Selectors. Your `msg.paylod` should look similar to--
```js
msg.payload = {
text: "This is a list",
footer: "nice footer, link: https://google.com",
title: "Amazing boldfaced list title",
buttonText: "Required, Tap to see List",
sections : [{
title: "Section 1",
rows: [
{title: "Option 1", rowId: "option1"},
{title: "Option 2", rowId: "option2", description: "This is a description"}
]},
{
title: "Section 2",
rows: [
{title: "Option 3", rowId: "option3"},
{title: "Option 4", rowId: "option4", description: "This is a description V2"}
]
}]
}
```
Yes its lot require for buttons, A node will come soon to minimize these effors.
You may direct import these test button with bellow code.
-*Don't forget to mention international dialing code befor your number. Number must be in format like `+11 99999 99999` without any space.*
</script>