Hello Zammad Community,
I’m currently working on integrating Zammad with Telegram via API, and I’m encountering an issue when trying to create tickets using the 'X-On-Behalf-Of'
header. Here’s the situation:
I’m using the following function to create a ticket in Zammad:
async function createTicketInZammad(customerId, userData) {
console.log(`Creating ticket for customer ID: ${customerId}`);
console.log("userData", JSON.stringify(userData));
try {
const response = await axios.post(`${zammadUrl}/tickets`, {
title: `Inquiry: ${userData.typeOfInquiry}`,
group: 'Support',
customer_id: customerId,
category: userData.typeOfInquiry,
contact_number: userData.email,
article: {
subject: `Issue: ${userData.priorityLevel} - ${userData.telegramUsername}`,
body: `Name: ${userData.name}\n\nDescription: ${userData.issueDescription}\n\nPhone No.: ${userData.email}\nType Of Inquiry: ${userData.typeOfInquiry}\nPriority: ${userData.priorityLevel}`,
type: "telegram personal-message",
sender: 'Customer',
internal: false
},
preferences: {
channel: "telegram personal-message",
telegram: {
bid: "xxxxxxxtelegram-id",
chat_id: userData.chatId
}
}
}, {
headers: {
'Authorization': `Bearer ${zammadToken}`,
'Content-Type': 'application/json',
'X-On-Behalf-Of': userData.telegramUsername
}
});
console.log('Ticket created:', response.data);
return response.data.id;
} catch (error) {
console.error('Error creating ticket:', error.response ? error.response.data : error.message);
return null;
}
}
When I do not include the 'X-On-Behalf-Of'
header, everything works as expected, and the preferences are applied correctly, including the channel being set to telegram personal-message
.
However, when I include the 'X-On-Behalf-Of'
header, the preferences are ignored, and the channel is set to "note"
instead of "telegram personal-message"
.
I need to use the 'X-On-Behalf-Of'
header because I want the username to appear in the Activity Stream notifications instead of my name. Is there a way to fix this so that the preferences (especially the channel) are still applied correctly while using the 'X-On-Behalf-Of'
header?
Any help would be appreciated. Thanks in advance!