Integrate IBM Watson Assistant with Zendesk
- Create an IBM Watson Assistant instance on IBM Cloud. Configure intents, entities, and dialog skills for your assistant.
- Set up a Zendesk account. Navigate to Admin > Channels > API, and create an API token for authentication.
- Use a middleware server to relay messages between Watson Assistant and Zendesk. Tools like Node.js or Python can be used to implement this middleware logic.
- In the middleware, authenticate Watson Assistant using an API key and authenticate Zendesk using the API token.
- Listen for incoming requests from Zendesk, send them to Watson Assistant and return the responses to Zendesk. Use the Watson Assistant's REST API endpoints to interact.
- Here's a basic Node.js example:
const express = require('express');
const watson = require('ibm-watson/assistant/v2');
const axios = require('axios');
const app = express();
const assistant = new watson.AssistantV2({
version: '2021-06-14',
authenticator: new watson.IamAuthenticator({ apikey: 'your-watson-api-key' }),
serviceUrl: 'your-watson-url',
});
app.post('/zendesk-webhook', (req, res) => {
assistant.message({
assistantId: 'your-assistant-id',
sessionId: 'your-session-id',
input: { text: req.body.message },
}).then(response => {
axios.post('https://your-zendesk-url.com/api/v2/tickets', {
comment: { body: response.result.output.generic[0].text }
}, {
headers: { 'Authorization': 'Bearer your-zendesk-api-token' }
});
res.status(200).send('Success');
}).catch(err => console.error(err));
});
app.listen(3000, () => console.log('Server is running'));
- Ensure your Node.js server is secure and consider scaling requirements.
- Test the integration thoroughly before deployment.