UNPKG

node-red-contrib-chatbot

Version:

REDBot a Chat bot for a full featured chat bot for Telegram, Facebook Messenger and Slack. Almost no coding skills required

15 lines (7 loc) 1.56 kB
The `Pop Message node` is useful with all the nodes (like [NLPjs Process](https://app.notion.com/p/bbc3deb2d39a4b338fc6515eee337cd4) , [MC GraphQL node](https://app.notion.com/p/0dc75116dee9458486e1a4f09fc3f44b) ) that overwrites the `msg.payload` of the **Node-RED** message, losing any reference with the original message from the chatbot user. The `Pop Message node` restores the previous value of `msg.payload` overwritten by these nodes. For example consider this flow when we want to query a database to check is the user is allowed to use the chatbot: ![Check user credentials](./docs/assets/f91b3ea0fc644412.png) The node [MC GraphQL node](https://app.notion.com/p/0dc75116dee9458486e1a4f09fc3f44b) is querying the database presenting the result in `msg.payload` overwriting the user’s message which is required in the rest of the flow. The `Function node` checks the result of the query and controls the flow: if the user is not allowed to use the chatbot the flow is redirected to the second pin and a _“Not allowed”_ message is answered. If the user has the right permission the flow is redirected to the first pin and the user’s message (the previous value of `msg.payload`) is restored to be used in the rest of the flow (for example a parse node). It’s possible to store the current message (`msg.payload`) with the `Push message node`, this is useful in all situations where the downstream node is overwriting the `payload` of the **Node-RED** message. **Warning:** it doesn’t work across **RedBot**’s senders and receivers