UNPKG

node-red-contrib-whatsapp-cmb

Version:
253 lines (244 loc) 10.9 kB
<script type='text/javascript'> RED.nodes.registerType('node-red-contrib-whatsapp-cmb-account', { category: 'config', icon: "whatsapp.svg", color: "#25D366", defaults: { name: {value: ""} }, credentials: { key: {type:"password"}, phonenumber: {type:"text"} }, label: function() { return this.name||"Whatsapp Account"; }, oneditsave: function(){ console.log('save', this); } }); </script> <script type='text/x-red' data-template-name='node-red-contrib-whatsapp-cmb-account'> <div class='form-row'> <label for='node-config-input-name'><i class='fa fa-tag'></i> Name</label> <input type='text' id='node-config-input-name' placeholder="Name for the account"/> </div> <div class='form-row'> <label for='node-config-input-phonenumber'><i class='fa fa-phone'></i> Phone</label> <input type='text' id='node-config-input-phonenumber' placeholder="Your phone number"/> </div> <div class='form-row'> <label for='node-config-input-key'><i class='fa fa-key'></i> API-KEY</label> <input type='password' id='node-config-input-key' placeholder="Your API-KEY for WhatsApp-CMB"/> </div> <div class="form-tips"> <p><b>Note</b>: How to create an API key? Show <a href="https://github.com/PfisterDaniel/node-red-contrib-whatsapp-cmb/blob/main/README.md#create-api-key">here</a> for more information.</p> </div> </script> <script type='text/javascript'> RED.nodes.registerType('node-red-contrib-whatsapp-cmb-send-message', { category: 'WhatsApp', icon: "whatsapp.svg", color: "#25D366", paletteLabel: 'Send Message', defaults: { name: { value: '', required: false }, credtype: { value: '', required: true }, account: {value: "", type:"node-red-contrib-whatsapp-cmb-account", required: false}, text:{ value: '', required: false, validate: RED.validators.typedInput('inputtype') }, phonenumbervalue:{ value: '', required: false, validate: RED.validators.typedInput('inputtype') }, apikeyvalue:{ value: '', required: false, validate: RED.validators.typedInput('inputtype') }, apikeyinputtypemessage: { value: 'msg' }, phonenumberinputtypemessage: { value: 'msg' }, inputtypemessage: { value: 'str' }, rejectssl: { value: false } }, label: function() { return this.name ? this.name : 'Send Message' }, inputs: 1, outputs: 1, oneditprepare: function(){ console.log('prepare', this); if (this.rejectssl === undefined) { $("#node-config-input-rejectssl").prop('checked', false); } $('#node-input-text').typedInput({ default: 'str', typeField: $("#node-input-inputtypemessage"), types: ['flow','global','msg','str'] }); $('#node-input-phonenumbervalue').typedInput({ default: 'msg', typeField: $("#node-input-phonenumberinputtypemessage"), types: ['flow','global','msg'] }); $('#node-input-apikeyvalue').typedInput({ default: 'msg', typeField: $("#node-input-apikeyinputtypemessage"), types: ['flow','global','msg'] }); $("#node-input-credtype").typedInput({ types: [ { value: "credtypes", options: [ { value: "account", label: "Account-Node"}, { value: "vars", label: "Variables"}, ] } ] }); $("#node-input-credtype").change(function () { switch ($(this).val()) { case 'account': console.log('Account') $('#row-apikey').hide(); $('#row-phonenumber').hide(); $('#row-account').show(); break case 'vars': console.log('Variables') $('#row-apikey').show(); $('#row-phonenumber').show(); $('#row-account').hide(); break default: console.log('default') } }) }, oneditsave: function() { console.log('save', this); }, oneditresize: function() { console.log('resize', this); } }) </script> <script type='text/x-red' data-template-name='node-red-contrib-whatsapp-cmb-send-message'> <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 for the node"/> </div> <div class="form-row"> <label for="node-input-credtype"><i class="fa fa-sign-in"></i> Credential-Type</label> <input type="text" id="node-input-credtype"> </div> <div class="form-row" id="row-account"> <label for="node-input-account"><i class="fa fa-user"></i> Account</label> <input type="text" id="node-input-account"> </div> <div class="form-row" id="row-apikey"> <label for="node-input-apikeyvalue"><i class="fa fa-key"></i> API-Key</label> <input type="text" id="node-input-apikeyvalue"> <input type="hidden" id="node-input-apikeyinputtypemessage"> </div> <div class="form-row" id="row-phonenumber"> <label for="node-input-phonenumbervalue"><i class="fa fa-mobile"></i> Phone-Number</label> <input type="text" id="node-input-phonenumbervalue"> <input type="hidden" id="node-input-phonenumberinputtypemessage"> </div> <div class="form-row"> <label for="node-input-text"><i class="fa fa-commenting-o"></i> Message</label> <!--<textarea id="node-input-text" rows="5" style="width:100%"></textarea>--> <input type="text" id="node-input-text" style="width:70%"> <input type="hidden" id="node-input-inputtypemessage"> </div> <div class="form-row"> <label for="node-input-rejectssl" style="width:160px"><i class="fa fa-shield"></i> Reject-Unauthorized:</label> <input type="checkbox" checked id="node-input-rejectssl" style="display:inline-block; width:auto; vertical-align:top;"> </div> <div class="form-tips"> <p><b>Note</b>: If you received the error "unable to get local issuer certificate", you can skip the error with "Reject-Unauthorized", but this is not a secure option.</p> </div> </script> <script type="text/html" data-help-name="node-red-contrib-whatsapp-cmb-send-message"> <p>Send a message with WhatsApp CallmeBot</p> <h3>Inputs</h3> <ol class="node-ports"> <li>Name</li> <li>Credential-Types <dl class="message-properties"> <dt> Account-Node <span class="property-type">value</span></dt> <dd> Using an Account-Node for the credential information</dd> <dt> Variables <span class="property-type">value</span></dt> <dd> Using a variable for the credential information</dd> </dl> </li> <li>API-Key <dl class="message-properties"> <dt>msg.< Element-Name > <span class="property-type">string</span></dt> <dd> Variable string from a previous node.</dd> <dd> Example: msg.apikey or msg.key</dd> <dt> flow.< Element-Name > <span class="property-type">string</span></dt> <dd> Variable string from a flow variable.</dd> <dd> Example: flow.apikey or flow.key</dd> <dt> global.< Element-Name > <span class="property-type">string</span></dt> <dd> Variable string from a global variable.</dd> <dd> Example: global.apikey or global.key</dd> </dl> </li> <li>Phone-Number <dl class="message-properties"> <dt>msg.< Element-Name > <span class="property-type">string</span></dt> <dd> Variable string from a previous node.</dd> <dd> Example: msg.phone or msg.number</dd> <dt> flow.< Element-Name > <span class="property-type">string</span></dt> <dd> Variable string from a flow variable.</dd> <dd> Example: flow.phone or flow.number</dd> <dt> global.< Element-Name > <span class="property-type">string</span></dt> <dd> Variable string from a global variable.</dd> <dd> Example: global.phone or global.number</dd> </dl> </li> <li>Message <dl class="message-properties"> <dt>str <span class="property-type">string</span></dt> <dd> Static String</dd> <dt>msg.< Element-Name > <span class="property-type">string</span></dt> <dd> Variable string from a previous node.</dd> <dd> Example: msg.payload or msg.text</dd> <dt>flow.< Element-Name > <span class="property-type">string</span></dt> <dd> Variable string from a flow variable.</dd> <dd> Example: flow.payload or flow.text</dd> <dt>global.< Element-Name > <span class="property-type">string</span></dt> <dd> Variable string from a global variable.</dd> <dd> Example: global.payload or global.text</dd> </dl> </li> </ol> <h3>Outputs</h3> <ol class="node-ports"> <li>Standard output <dl class="message-properties"> <dt>payload <span class="property-type">string</span></dt> <dd>the standard output of the command.</dd> </dl> </li> <li>Standard error <dl class="message-properties"> <dt>error <span class="property-type">string</span></dt> <dd>the standard error of the command.</dd> </dl> </li> </ol> </script>