Conversations Inbox | Integration with Cognigy

Welcome to the tutorial on how to integrate Cognigy with tyntec Conversations Inbox in 5 steps. To provide options for different users, we've prepared two variants of Cognigy settings for you: 

The simpler “pre-build” variant includes a pre-build package that is easy to implement with our guide. It is suitable for users with experience with Cognigy and just want to test tyntec integration.

The second “complete” variant is more complex and describes the complete procedure to set up Cognigy and the whole flow of the new agent. It is suitable for users who have no experience with Cognigy and want to build their workflow on their own.

You will need

Pre-build variant: Made it easy

1. Create a virtual agent

Let's start with creating the first virtual agent.

    1. Click the Create agent button.
    2. Fill your
agent name - Main and language.
    3. Select Solution Accelerator - Blank.
   
4. Select
Webchat.
    5. Go to your new Agent.

The new agent is successfully set up and ready to import packages.

More information about creating a virtual agent can be found here.

2. Import package

    1. Download the pre-build package here.
    2. Select
Manage - Packaging.

    3. Click Browse file.
    4. Select the whole .zip file.
    5. Click
Import.

    6. Click Start Over.

The import of the package is done, now the flows are set and ready to build the model.

3. Build a Model

    1. Go to Build - Flows.

    2. Select Main.
    3. Click
Build Model.

The model is built, which means flow is ready to use. All that's left is to fill in the key parameters.

4. Configure the default context

    1. Go to Build/Flows/Main/Settings/Default Context.
   
2. Replace
YOURAPIKEY with your tyntec Conversations Inbox API key.
    3. Click
Save.

Filling in the API key connects Cognigy to tyntec.

More information about Context can be found here.

5. Configure the assignee

    1. Go to Build - Flows
    2. Select
Main.
    3. Select
Handover node.
    4. In
Payload, replace YOURASSIGNEEJID with your assignee's JID.

All set. Thanks to this process, the agent is set up correctly, including the REST API endpoints. You can now start using the agent for your customer conversations.

Complete variant: Full guide for integrating Cognigy with tyntec Conversations Inbox

1. Create a virtual agent

Let's start with creating the first virtual agent.

    1. Click the Create agent button.
    2. Fill in your
virtual agent name and language.
    3. Select
Solution Accelerator - Blank.
    
4. Select
Webchat.
    5. Save the new
virtual agent.

The new agent is successfully set up and ready to configure the default context.

More information about creating a virtual agent can be found here.

2. Configure the default context

    1. Go to Build/Flows/Main/Settings/Default Context.
    2. Insert this code:

{
"apikey": "YOURAPIKEY"
}

    3. Replace YOURAPIKEY with your tyntec Conversations Inbox API key.

Filling in the API key connects Cognigy to tyntec.

More information about Context can be found here.

 

3. Build a new flow

    1. Select Flow.
    2. Click
New Flow.
    
3. Fill name of new Flow.
    4. Save it.
    5. Start building a new Flow. Your flow should look like this:

More information about building flows can be found here.

4. Make your agent act based on user intent

    1. Case (tryOn):

  • Click on the + icon. 
  • Add HTTP Request node.
  • HTTP Request Method: POST
  • URL:https://api.cmd.tyntec.com/v3/channels/{{input.data.channelJid}}/messages/{{input.userId}}
  • Payload Type: JSON
  • Payload:
 "message": {
   "body": "Hi {{ input.data.fromName }}, happy to assist you with scheduling your try-on. Would you like to come to one of our stores or should we ship the shoes to you?",
   "type": "text"
 }
}
  • Headers key: Authorization
  • Headers value: Bearer {{context.apikey}}
  • Error Handling - Abort Flow Execution on Error: ON

    2. Case (Default)

  • Click on the + icon. 
  • Add HTTP Request node.
  • HTTP Request Method: POST
  • URL:https://api.cmd.tyntec.com/v3/channels/{{input.data.channelJid}}/messages/{{input.userId}}
  • Payload Type: JSON
  • Payload:
{
  "message": {
    "body": "Great! Since you’re our VIP customer, our store associate will take over this conversation to make sure everything’s ready for your visit. One short moment, please…",
    "type": "text"
  }
}
  • Headers key: Authorization
  • Headers value: Bearer {{context.apikey}}
  • Error Handling - Abort Flow Execution on Error: ON

    3. Case (Default)

  • Click on the + icon. 
  • Add another HTTP Request node.
  • HTTP Request Method: PATCH
  • URL:https://api.cmd.tyntec.com/v3/channels/{{input.data.channelJid}}/conversations/{{input.userId}}
  • Payload Type: JSON
  • Payload:
{
    "assignee": "YOURASSIGNEEJID"
}
  • Replace YOURASSIGNEDJID with your assignee's JID 
  • Headers key: Authorization
  • Headers value: Bearer {{context.apikey}}
  • Error Handling - Abort Flow Execution on Error: ON

At the end workflow should look like this:

Flow is created, giving the agent's basic options for communicating with the customer.

More information about HTTP requests can be found here.

5. Set up a REST endpoint

    1. Select Deploy - Endpoints.
    2. Click
New Endpoint.
    3. Create a
New REST API Endpoint assigned to your flow.
    4. Open new REST API Endpoint.
    5. Open
Transformer Functions.
    6. Enable
Abort on Error in Transformer.
   
7. Enable
Input Transformer.
    8. Insert this code into the Transformer:

createRestTransformer({
   handleInput: async ({ endpoint, request, response }) => {
       return {
           userId: request.body.from.jid,
           sessionId: request.body.contextInfo.conversation.id,
           text: request.body.message.body,
           data: {
               channelJid: request.body.to,
               fromName: request.body.from.name
           }
       };
   },
   handleOutput: async ({ output, endpoint, userId, sessionId }) => {
       return output;
   },
   handleExecutionFinished: async ({ processedOutput, outputs, userId, sessionId, endpoint, response }) => {
       return processedOutput;
   }
});

Connect Cognigy to Conversations Inbox

Once your Cognigy agent is ready it's time to connect it to the tyntec Conversations Inbox.

    1. Open tyntec Conversations Inbox.
    2. Select Conversation you want to assign to Cognigy bot.
    3. Click on pulldown under name.
    4. Select
Assistants.
    5. Select
Outreach Demo.

And that's it. Now you can start using Cognigy in your Conversations Inbox.

More?

Cognigy can be modified in many ways. It offers a large amount of flows that you can use for your Cognigy agents. You can also use this integration with others like CRM systems. For example, you can use Cognigy and Salesforce at the same time for your Conversations Inbox (check out the Salesforce-tyntec integration tutorial).

Use Case Demo

See how you can use the Cognigy integration together with Salesforce in Conversations Inbox.