Freshdesk Integration
Freshdesk Integration
Integrating Kommunicate with Freshdesk yields a seamless and comprehensive customer support solution, offering several advantages. By combining Kommunicate's AI chatbot functionality with Freshdesk's ticketing system, businesses can provide real-time support across channels, ensuring prompt query resolution.
Freshdesk Ticket Integration in Kommunicate
Following are the steps to integrate the Freshdesk ticket in Kommunicate:
- Login to your Freshdesk account >> Click on Profile >> Profile settings >> View API Key. Complete the captcha and copy your API key.
- For this example, we have created a button called Create a support ticket that displays a form with the fields Email, Subject and Description. When the user fills the form and clicks on Submit an intent with the training phrase Submit is triggered which consists of the inline code to create a Freshdesk ticket.
Login to Kommunicate >> Create a button to display a form >> Create an intent to triggers the Inline code which creates the ticket on Freshdesk.
You can learn how to use the form from here and you can learn how to use the inline code from here.
You can follow the below steps to add the form payload.
You can follow the below steps to add the Inline code.
The payload for the form used for this example is given below:
{
"message": "Please enter the following details",
"platform": "kommunicate",
"metadata": {
"contentType": "300",
"templateId": "12",
"payload": [
{
"type": "text",
"data": {
"label": "Email",
"placeholder": "Please enter your Email"
}
},
{
"type": "text",
"data": {
"label": "Subject",
"placeholder": "Enter the subject for the ticket"
}
},
{
"type": "text",
"data": {
"label": "Description",
"placeholder": "Briefly explain the issue"
}
},
{
"type": "submit",
"data": {
"action": {
"message": "submit",
"postFormDataAsMessage": "false",
"postBackToBotPlatform": "false",
"requestType": "postBackToBotPlatform"
},
"type": "submit",
"name": "Submit"
}
}
]
}
}
The Inline code used is given below:
In the below Inline code replace Your_Freshdesk_Api_Key
with your Freshdesk API key retrieved in step 1.
Also, replace Your_Freshdesk_Domain
with your Freshdesk domain.
exports.responseHandler = async (input, callback) => {
try {
const apiKey = 'Your_Freshdesk_Api_Key';
const encodedApiKey = Buffer.from(`${apiKey}:X`).toString('base64');
const url = 'https://Your_Freshdesk_Domain.freshdesk.com/api/v2/tickets';
const response = await axios.post(url, {
description:input.metadata.KM_CHAT_CONTEXT.formData.Description,
subject:input.metadata.KM_CHAT_CONTEXT.formData.Subject,
email:input.metadata.KM_CHAT_CONTEXT.formData.Email,
priority: 1,
status: 2,
}, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${encodedApiKey}`
}
});
callback([{ "message": "Ticket created successfully." }]);
} catch (error) {
console.error('Error creating ticket:', error);
callback([{ "message": `Please enter a valid Email Id` }]);
}
};
In the following code, the description
, subject
and email
are set to the values entered in the form by the user. If you are using a different form you need to change this code to match your fields.
description:input.metadata.KM_CHAT_CONTEXT.formData.Description,
subject:input.metadata.KM_CHAT_CONTEXT.formData.Subject,
email:input.metadata.KM_CHAT_CONTEXT.formData.Email,
Ticket Creation on Freshdesk
The tickets are created on Freshdesk under the Tickets
section.
You can watch a demo tutorial from here.