createRestTransformer({ handleInput: async ({ endpoint, request, response }) => { const userId = ""; const sessionId = ""; const text = ""; const data = {} return { userId, sessionId, text, data }; }, handleOutput: async ({ output, endpoint, userId, sessionId }) => { return output; }, handleExecutionFinished: async ({ processedOutput, outputs, userId, sessionId, endpoint, response }) => { return processedOutput; } });
If you already played around with the Cognigy.AI platform you may have considered that there is no native WhatsApp channel connector (Endpoint) yet. However, with the help of tyntec this challenge can be completed very easily since they offer simple to use communication APIs for Messaging, Chat Apps, Number Data, and Authentication. In order to finally have a nice chat with our AI, a few steps need to be followed:
2. Set up a WhatsApp Business Account and connect it to tyntec

3. Inside Cognigy, define an Endpoint Transformer function to prepare the AI’s output to be displayed in WhatsApp
Create an Endpoint Transformer Function
After steps 1 and 2 are completed, our Cognigy output needs to be converted into a valid WhatsApp message. Therefore, this tutorial uses the following two Cognigy project resources:
Please add a simple SAY node to your flow and insert a nice welcome message:
Hi, \uD83D\uDC4B I am your personal WhatsApp assistant. How can I help you?
In the REST endpoint, this message now will be converted. In order to do so, navigate to the Endpoints section and click on your recently created REST endpoint. If you click on the Transformer Functions expansion panel, it opens the detail view to define our transformer:

The root function createRestTransformer() contains three more functions that are provided to manipulate incoming and outgoing data content: handleInput(), handleOutput() and handleExecutionFinished(), in which the last one is the one we will implement in the next step.
As can be seen in the tyntec's Conversations API, WhatsApp requires the following input information in order to send a simple text message:
"whatsapp": { "from": "545345345", "contentType": "text", "text": "Hi, \uD83D\uDC4B I am your personal WhatsApp assistant. How can I help you?" }
return await httpRequest({ uri: "https://api.tyntec.com/chat-api/v2/messages", method: "POST", headers : { 'Content-Type':'application/json', 'Accept':'application/json', 'apikey': '098765434567' }, body: { "to": sessionId, "channels": [ "whatsapp" ], "whatsapp": { "whatsapp": { "from": "545345345", "contentType": "text", "text": "Hi, \uD83D\uDC4B I am your personal WhatsApp assistant. How can I help you?" } } }, json: true });
