createRestTransformer({ handleInput: async ({ endpoint, request, response }) => { return { userId: request.body.from, sessionId: JSON.stringify([request.body.from, request.body.to]), text: undefined, data: request.body.content }; }, handleOutput: async ({ output, endpoint, userId, sessionId }) => { return output; }, handleExecutionFinished: async ({ processedOutput, outputs, userId, sessionId, endpoint, response }) => { return await httpRequest({ uri: "https://api.tyntec.com/conversations/v3/messages", method: "POST", headers : { 'Content-Type':'application/json', 'Accept':'application/json', 'apikey': APIKEY // replace APIKEY with your tyntec API key }, body: { "to": userId, "from": WABA, // replace WABA with your WABA phone number "channel" : "whatsapp", "content" : { "contentType": "text", "text": processedOutput.text } }, json: true }); } });
You will need
- Your tyntec API key from your tyntec account
- Your WABA phone number that has been assigned to you by tyntec
- A mobile phone with the WhatsApp application not associated with your WABA
- A Cognigy.AI account
- Postman installed


You’ve created a bot that is designed to automatically handle interactions.


Congratulations. Now, your agent can reply with a warm message to your customers.


Everything is up and running. Good job!
Step Four: Let the Conversations API know about your agent
Let the tyntec Conversations API know where to deliver WhatsApp messages from customers or your users. You’re going to subscribe to the agent’s endpoint via an API call in Postman.
1. From the api-collection/conversations/v3 directory, import the Conversations V3.5.postman_collection.json into Postman.
2. Authorize Postman with your tyntec API key and your WABA phone number. Right-click the collection and select Edit. Then go to Variables and set the apiKey variable to your tyntec API key. Also, set the wabaNumber variable to your WABA phone number.
3. Let's set up a webhook! Open the WhatsApp folder. Inside, open the Configurations folder and select the Configure the callback for a specific number request and change the inboundMessageUrl in the body to the agent’s endpoint URL (for example, https://endpoint-trial.cognigy.ai/4cc724847b66e4a3af5aa3bb555ed9595a1e09a5be496358976afa16efc070b3). This request will subscribe the URL to incoming message events.

Cool! Now Conversations API knows where to deliver WhatsApp messages from your customers.

Cool! Your new Cognigy agent can talk to anyone via WhatsApp!
More?
Utilizing Cognigy's platform you can make your agent smarter. Look at the official Train your Virtual Agent to recognize Intents tutorial and configure your responses. For example, you may want to update the Say node with a snappy meme using an image message or with a funny cat video using a video message. Moreover, you can use the Say node Text with Buttons in cooperation with WhatsApp interactive messages.
To protect the agent’s endpoint against unauthorized messages, you may register the webhook with a custom header containing a bearer token. Then, you can check the request headers in the transformer’s handleInput function and throw an error if the request does not contain the token.